Name

NSString — Mac OS X 10.0

Synopsis

This is Foundation’s primary class for representing and manipulating strings. At their core, instances of NSString are an immutable array of Unicode characters. With built-in, low-level support of Unicode, Cocoa applications can represent nearly every written language in existence, past and present. NSString is toll-free bridged with the Core Foundation type CFString. As such, NSString objects can be used interchangeably with the CFString pointer type, CFStringRef.

image with no caption

@interface NSString : NSObject <NSCoding, NSCopying, NSMutableCopying>
                                  // Convenience Constructors
   + (id)string;
   + (id)stringWithCString:(const char *)bytes;
   + (id)stringWithCString:(const char *)bytes 
                                 length:(unsigned)length;
   + (id)stringWithCharacters:(const unichar *)characters  
                                 length:(unsigned)length;
   + (id)stringWithContentsOfFile:(NSString *)path;
   + (id)stringWithContentsOfURL:(NSURL *)url;
   + (id)stringWithFormat:(NSString *)format, ...;
   + (id)stringWithString:(NSString *)string;
   + (id)stringWithUTF8String:(const char *)bytes;
                                  // Initializers
   - (id)init;
   - (id)initWithCString:(const char *)bytes;
   - (id)initWithCString:(const char *)bytes 
                                 length:(unsigned)length;
   - (id)initWithCStringNoCopy:(char *)bytes  
                                 length:(unsigned)length 
                                 freeWhenDone:(BOOL)freeBuffer;
   - (id)initWithCharacters:(const unichar *)characters 
                                 length:(unsigned)length;
 - (id) ...

Get Cocoa in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.