O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSMutableString — Mac OS X 10.0

Synopsis

NSString creates immutable strings that cannot be changed after the object has been created. NSMutableString adds methods that allow the contents of NSMutableString objects to be altered after object initialization. This class provides methods for replacing portions of a string with another string, inserting strings within the existing string, appending strings and formats, as well as deleting portions of strings.

NSMutableString is toll-free bridged with the Core Foundation type CFString. As such, NSMutableString objects can be used interchangeably with the CFString pointer type, CFStringRef.

image with no caption

@interface NSMutableString : NSString
                                  // Initializers
   - (id)initWithCapacity:(unsigned)capacity;
                                  // Accessor Methods
   - (void)setString:(NSString *)aString;
                                  // Class Methods
   + (id)stringWithCapacity:(unsigned)capacity;
                                  // Instance Methods
   - (void)appendFormat:(NSString *)format, ...;
   - (void)appendString:(NSString *)aString;
   - (void)deleteCharactersInRange:(NSRange)range;
   - (void)insertString:(NSString *)aString 
                                 atIndex:(unsigned)loc;
   - (void)replaceCharactersInRange:(NSRange)range  
                                 withString:(NSString *)aString;
   - (unsigned int)replaceOccurrencesOfString:(NSString *)target
                                 withString:(NSString *)replacement 
                                 options:(unsigned)opts 
                                 range:(NSRange)searchRange;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required