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

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) ...

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