| Sign In/My Account | View Cart |
| Article: |
Strings in Cocoa: Part I | |
| Subject: | Comparing strings | |
| Date: | 2001-07-04 18:36:41 | |
| From: | bigboytoddy | |
|
Response to: Comparing strings
|
||
|
Okay, so when are each used, and why? I appreciate the ANSI C lessons here, as it seems it is a ANSI issue, which brings me to ask why (again)? Where would this differentiation make a slack ass like me what to know the difference...?
|
||
Showing messages 1 through 1 of 1.
For example consider:
char* aString = "hello";
and later
char* bString = "hello"
the compiler has permission to notice that aString == bString and just reuse aString.
The second form says that you might want to change bString later and you don't want that to effect aString so they must be stored separately. But you won't need this second form in ObjC because you can use NSMutableString instead.
Of course the best rule for C style strings is don't use them at all. They are just too complicated and error prone.