Changes

Jump to: navigation, search

Working with String Objects in Objective-C

302 bytes added, 20:31, 3 November 2009
Creating Mutable and Immutable String Objects
</pre>
Mutable string objects, on the other hand, are declared using the ''NSMutableString'' class and allow the string contained within the object to be modified using a variety of methods (some of which will be covered in the remainder of this chapter). NSMutableString is a subclass of NSString, which in turn is a subclass of NSObject.Mutable strings cannot be initialized simply by assigning a constant string object as we did above since that will just give us a pointer to an immutable constant string object. Instead, the string constant must be copied into the mutable string object. For example:
<pre>
NSMutableString *string2 = [NSMutableString stringWithString:@"This string is mutable"];
</pre>

Navigation menu