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.
@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)initWithCharactersNoCopy:(unichar *)characters length:(unsigned)length freeWhenDone:(BOOL)freeBuffer;
|
- (id)initWithContentsOfFile:(NSString *)path;
|
- (id)initWithContentsOfURL:(NSURL *)url;
|
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding;
|
- (id)initWithFormat:(NSString *)format arguments:(va_list)argList;
|
- (id)initWithFormat:(NSString *)format locale:(NSDictionary *)dict arguments:(va_list)argList;
|
- (id)initWithFormat:(NSString *)format locale:(NSDictionary *)dict, ...;
|
- (id)initWithFormat:(NSString *)format, ...;
|
- (id)initWithString:(NSString *)aString;
|
- (id)initWithUTF8String:(const char *)bytes;
|
// Class Methods |
+ (const NSStringEncoding *)availableStringEncodings;
|
+ (NSStringEncoding)defaultCStringEncoding;
|
+ (NSString *)localizedNameOfStringEncoding:(NSStringEncoding)encoding;
|
+ (id)localizedStringWithFormat:(NSString *)format, ...;
|
+ (NSString *)pathWithComponents:(NSArray *)components;
|
// Instance Methods |
- (const char *)UTF8String;
|
- (const char *)cString;
|
- (unsigned)cStringLength;
|
- (BOOL)canBeConvertedToEncoding:(NSStringEncoding)encoding;
|
- (NSString *)capitalizedString;
|
- (NSComparisonResult)caseInsensitiveCompare:(NSString *)string;
|
- (unichar)characterAtIndex:(unsigned)index;
|
- (NSString *)commonPrefixWithString:(NSString *)aString options:(unsigned)mask;
|
- (NSComparisonResult)compare:(NSString *)string;
|
- (NSComparisonResult)compare:(NSString *)string options:(unsigned)mask;
|
- (NSComparisonResult)compare:(NSString *)string options:(unsigned)mask range:(NSRange)compareRange;
|
- (NSComparisonResult)compare:(NSString *)string options:(unsigned)mask range:(NSRange)compareRange
locale:(NSDictionary *)dict;
|
- (unsigned)completePathIntoString:(NSString **)outputName caseSensitive:(BOOL)flag
matchesIntoArray:(NSArray **)outputArray filterTypes:(NSArray *)filterTypes;
|
- (NSArray *)componentsSeparatedByString:(NSString *)separator;
|
- (NSData *)dataUsingEncoding:(NSStringEncoding)encoding;
|
- (NSData *)dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy;
|
- (NSString *)decomposedStringWithCanonicalMapping;
|
- (NSString *)decomposedStringWithCompatibilityMapping;
|
- (NSString *)description;
|
- (double)doubleValue;
|
- (NSStringEncoding)fastestEncoding;
|
- (const char *)fileSystemRepresentation;
|
- (float)floatValue;
|
- (void)getCString:(char *)bytes;
|
- (void)getCString:(char *)bytes maxLength:(unsigned)maxLength;
|
- (void)getCString:(char *)bytes maxLength:(unsigned)maxLength range:(NSRange)aRange
remainingRange:(NSRangePointer)leftoverRange;
|
- (void)getCharacters:(unichar *)buffer;
|
- (void)getCharacters:(unichar *)buffer range:(NSRange)aRange;
|
- (BOOL)getFileSystemRepresentation:(char *)cname maxLength:(unsigned)max;
|
- (void)getLineStart:(unsigned *)startPtr end:(unsigned *)lineEndPtr contentsEnd:(unsigned *)contentsEndPtr
forRange:(NSRange)range;
|
- (BOOL)hasPrefix:(NSString *)aString;
|
- (BOOL)hasSuffix:(NSString *)aString;
|
- (unsigned)hash;
|
- (int)intValue;
|
- (BOOL)isAbsolutePath;
|
- (BOOL)isEqualToString:(NSString *)aString;
|
- (NSString *)lastPathComponent;
|
- (unsigned int)length;
|
- (NSRange)lineRangeForRange:(NSRange)range;
|
- (NSComparisonResult)localizedCaseInsensitiveCompare:(NSString *)string;
|
- (NSComparisonResult)localizedCompare:(NSString *)string;
|
- (const char *)lossyCString;
|
- (NSString *)lowercaseString;
|
- (NSArray *)pathComponents;
|
- (NSString *)pathExtension;
|
- (NSString *)precomposedStringWithCanonicalMapping;
|
- (NSString *)precomposedStringWithCompatibilityMapping;
|
- (id)propertyList;
|
- (NSDictionary *)propertyListFromStringsFileFormat;
|
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet;
|
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet options:(unsigned int)mask;
|
- (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet
options:(unsigned int)mask range:(NSRange)searchRange;
|
- (NSRange)rangeOfComposedCharacterSequenceAtIndex:(unsigned)index;
|
- (NSRange)rangeOfString:(NSString *)aString;
|
- (NSRange)rangeOfString:(NSString *)aString options:(unsigned)mask;
|
- (NSRange)rangeOfString:(NSString *)aString options:(unsigned)mask range:(NSRange)searchRange;
|
- (NSStringEncoding)smallestEncoding;
|
- (NSString *)stringByAbbreviatingWithTildeInPath;
|
- (NSString *)stringByAppendingFormat:(NSString *)format, ...;
|
- (NSString *)stringByAppendingPathComponent:(NSString *)str;
|
- (NSString *)stringByAppendingPathExtension:(NSString *)str;
|
- (NSString *)stringByAppendingString:(NSString *)aString;
|
- (NSString *)stringByDeletingLastPathComponent;
|
- (NSString *)stringByDeletingPathExtension;
|
- (NSString *)stringByExpandingTildeInPath;
|
- (NSString *)stringByPaddingToLength:(unsigned)newLength withString:(NSString *)padString
startingAtIndex:(unsigned)padIndex;
|
- (NSString *)stringByResolvingSymlinksInPath;
|
- (NSString *)stringByStandardizingPath;
|
- (NSString *)stringByTrimmingCharactersInSet:(NSCharacterSet *)set;
|
- (NSArray *)stringsByAppendingPaths:(NSArray *)paths;
|
- (NSString *)substringFromIndex:(unsigned)from;
|
- (NSString *)substringToIndex:(unsigned)to;
|
- (NSString *)substringWithRange:(NSRange)range;
|
- (NSString *)uppercaseString;
|
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;
|
- (BOOL)writeToURL:(NSURL *)url atomically:(BOOL)atomically;
|
// Methods Implementing NSCoding |
- (void)encodeWithCoder:(NSCoder *)aCoder;
|
- (id)initWithCoder:(NSCoder *)aDecoder;
|
// Methods Implementing NSCopying |
- (id)copyWithZone:(NSZone *)zone;
|
// Methods Implementing NSMutableCopying |
- (id)mutableCopyWithZone:(NSZone *)zone;
|