iOS8最新API和一些生僻API,做了紅色標注,便於大家查閱。 //0.定義一個無符號整型 兩個字節 范圍[0,65535] typedef unsigned short unichar; //1.提前進入以下六個類告訴編譯器,六個都是類的名稱 @classNSData,NSArray,NSDictionary,NSCharacterSet,NSURL,NSError,NSLocale; //2.異常處理字符串,控制台出錯信息報告 FOUNDATION_EXPORTNSString *const NSParseErrorException; //3.宏定義下字符串的最大值 #define NSMaximumStringLength (INT_MAX-1) //4.字符串進行比較options typedefNS_OPTIONS(NSUInteger, NSStringCompareOptions) { NSCaseInsensitiveSearch =1,//兩個字符串的比較不區分大小寫 NSLiteralSearch = 2,//兩個字符串的比較區分大小寫 NSBackwardsSearch =4,//從字符串末尾開發查詢搜索 NSAnchoredSearch =8,//搜索有限制范圍的字符串 NSNumericSearch = 64,//根據字符串裡的數字來計算順序 NSDiacriticInsensitiveSearchNS_ENUM_AVAILABLE(10_5,2_0) =128, NSWidthInsensitiveSearch NS_ENUM_AVAILABLE(10_5,2_0) =256,//可以忽略字符串的寬度(長度)比較結果 NSForcedOrderingSearchNS_ENUM_AVAILABLE(10_5,2_0) =512,//忽略不區分大小寫比較的選項 NSRegularExpressionSearchNS_ENUM_AVAILABLE(10_7,3_2) =1024 // }; //5.字符串編碼的多種選項 enum { NSASCIIStringEncoding =1,/* 0..127 only */ NSNEXTSTEPStringEncoding =2, NSJapaneseEUCStringEncoding =3, NSUTF8StringEncoding =4, NSISOLatin1StringEncoding =5, NSSymbolStringEncoding =6, NSNonLossyASCIIStringEncoding =7, NSShiftJISStringEncoding =8, /* kCFStringEncodingDOSJapanese */ NSISOLatin2StringEncoding =9, NSUnicodeStringEncoding =10, NSWindowsCP1251StringEncoding = 11, /* Cyrillic; same as AdobeStandardCyrillic */ NSWindowsCP1252StringEncoding =12, /* WinLatin1 */ NSWindowsCP1253StringEncoding =13, /* Greek */ NSWindowsCP1254StringEncoding =14, /* Turkish */ NSWindowsCP1250StringEncoding =15, /* WinLatin2 */ NSISO2022JPStringEncoding = 21, /* ISO 2022 Japanese encoding for e-mail */ NSMacOSRomanStringEncoding =30, NSUTF16StringEncoding = NSUnicodeStringEncoding, /* An alias for NSUnicodeStringEncoding */ NSUTF16BigEndianStringEncoding = 0x90000100, /* NSUTF16StringEncoding encoding with explicit endianness specified */ NSUTF16LittleEndianStringEncoding = 0x94000100, /* NSUTF16StringEncoding encoding with explicit endianness specified */ NSUTF32StringEncoding =0x8c000100, NSUTF32BigEndianStringEncoding = 0x98000100, /* NSUTF32StringEncoding encoding with explicit endianness specified */ NSUTF32LittleEndianStringEncoding = 0x9c000100 /* NSUTF32StringEncoding encoding with explicit endianness specified */ }; //6.字符串編碼 typedefNSUInteger NSStringEncoding; 字符串編碼轉換條件option,下面指定緩沖區轉換會用到 typedefNS_OPTIONS(NSUInteger, NSStringEncodingConversionOptions) { NSStringEncodingConversionAllowLossy =1, NSStringEncodingConversionExternalRepresentation =2 }; //7.字符轉化異常 FOUNDATION_EXPORTNSString *const NSCharacterConversionException; //8. NSString繼承NSObject,並遵守以下三個協議 @interface NSString :NSObject <NSCopying,NSMutableCopying,NSSecureCoding> //9.只讀屬性字符串長度length @property (readonly)NSUInteger length; //10.選取字符串對應下表的字符 -(unichar)characterAtIndex:(NSUInteger)index; //11.字符串的init初始化方法 -(instancetype)initNS_DESIGNATED_INITIALIZER; //12.當一個xib的控件被加載實例化的時候,系統會默認調用這個方法。 - (instancetype)initWithCoder:(NSCoder *)aDecoderNS_DESIGNATED_INITIALIZER; @end //13.NSString的擴展方法 @interface NSString (NSStringExtensionMethods) //14.截取字符串的指定段 - (void)getCharacters:(unichar *)buffer range:(NSRange)aRange; //15.截取指定位置Index之後字符串 - (NSString *)substringFromIndex:(NSUInteger)from; //16.從索引0第一個字符串開始,截取指定長度的字符串 - (NSString *)substringToIndex:(NSUInteger)to; //17.截取字符串的指定段,返回值為NSString - (NSString *)substringWithRange:(NSRange)range; //18.比較兩個字符串 - (NSComparisonResult)compare:(NSString *)string; //19.比較兩個字符串,並加上條件 - (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask; //20.比較兩個字符串,並加上某些條件到指定段 - (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange; //21.比較兩個字符串,並加上某些條件還有本地化語言環境,在指定段進行比較 - (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange locale:(id)locale; //22.不區分大小寫比較字符串 - (NSComparisonResult)caseInsensitiveCompare:(NSString *)string; //23.本地化比較字符串 - (NSComparisonResult)localizedCompare:(NSString *)string; //24.不區分大小寫以及本地化比較字符串 - (NSComparisonResult)localizedCaseInsensitiveCompare:(NSString *)string; //25.本地化標准字符串比較,返回升序降序相等 - (NSComparisonResult)localizedStandardCompare:(NSString *)stringNS_AVAILABLE(10_6,4_0); //26.比較兩個字符串是否相等 - (BOOL)isEqualToString:(NSString *)aString; //27.測試字符串是否以aString開頭 - (BOOL)hasPrefix:(NSString *)aString; //28.測試字符串是否以aString結尾 - (BOOL)hasSuffix:(NSString *)aString; //29.判斷字符串A是否包含aString字符串B,返回值Bool - (BOOL)containsString:(NSString *)aStringNS_AVAILABLE(10_10,8_0); //30.這是iOS8的新特性API 判斷字符串A是否包含字符串B,不區分大小寫,返回Bool 例:NSSsring * stringA = @“abcd”; NSSsring * stringB = @“d”; BOOl test = [stringA localizedCaseInsensitiveContainsString:stringB]; 輸出打印值 YES - (BOOL)localizedCaseInsensitiveContainsString:(NSString *)aString NS_AVAILABLE(10_10, 8_0); //31.搜索一個字符串是否包含某個字符 rangeOfString前面的參數是要被搜索的字符串,後面的是要搜索的字符 - (NSRange)rangeOfString:(NSString *)aString; //32.搜索一個字符串是否包含某個字符,並添加篩選條件option - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptions)mask; //33搜索一個字符串是否包含某個字符,添加篩選條件以及搜索的范圍range - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptions)mask range:(NSRange)searchRange; //34.搜索一個字符串是否包含某個字符,添加篩選條件以及搜索的范圍range,最後還有本地化的設置 - (NSRange)rangeOfString:(NSString *)aString options:(NSStringCompareOptions)mask range:(NSRange)searchRange locale:(NSLocale *)localeNS_AVAILABLE(10_5,2_0); //35.指定字符集進行搜索 - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet; //36.指定字符集進行搜索,並且加上某些限制條件 - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet options:(NSStringCompareOptions)mask; //37.指定字符集進行搜索,並且加上某些限制條件,且在指定的位置段進行 - (NSRange)rangeOfCharacterFromSet:(NSCharacterSet *)aSet options:(NSStringCompareOptions)mask range:(NSRange)searchRange; //38.用字符串的字符編碼指定索引查找位置 - (NSRange)rangeOfComposedCharacterSequenceAtIndex:(NSUInteger)index; //39.用字符串的字符編碼指定區域段查找位置 - (NSRange)rangeOfComposedCharacterSequencesForRange:(NSRange)rangeNS_AVAILABLE(10_5,2_0); //40.將aString字符串添加到前面字符串A的後面 - (NSString *)stringByAppendingString:(NSString *)aString; //41.將多個字符串添加到前面字符串A的後面 - (NSString *)stringByAppendingFormat:(NSString *)format, ...NS_FORMAT_FUNCTION(1,2); //42.只讀屬性 double類型 @property (readonly)double doubleValue; //43.只讀屬性 float類型 @property (readonly)float floatValue; //44.只讀屬性int類型 @property (readonly)int intValue; //45.只讀屬性NSInteger類型 @property (readonly)NSInteger integerValueNS_AVAILABLE(10_5,2_0); // 46.只讀屬性long long 類型 @property (readonly)longlong longLongValueNS_AVAILABLE(10_5,2_0); //47.只讀屬性BOOL類型 @property (readonly)BOOL boolValueNS_AVAILABLE(10_5,2_0); // //48.將字符串根據傳進來的字符串參數separator進行分割,並轉化成數組 - (NSArray *)componentsSeparatedByString:(NSString *)separator; // 49. 將字符串根據傳進來的字符編碼separator進行分割,並拆分成數組返回 - (NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)separatorNS_AVAILABLE(10_5,2_0); //50. - (NSString *)commonPrefixWithString:(NSString *)aString options:(NSStringCompareOptions)mask; //51. 將字符串的所有字符轉化成大寫 @property (readonly,copy)NSString *uppercaseString; //52.將字符串的所有字符轉化為小寫 @property (readonly,copy)NSString *lowercaseString; // 53. 所有單詞的首字母轉化成大寫 @property (readonly,copy)NSString *capitalizedString; //54.所有字符轉化成大寫 本地化 - (NSString *)uppercaseStringWithLocale:(NSLocale *)localeNS_AVAILABLE(10_8,6_0); //55.所有字符串轉化成小寫 本地化 - (NSString *)lowercaseStringWithLocale:(NSLocale *)localeNS_AVAILABLE(10_8,6_0); //54.所有單詞首字母轉化成大寫 本地化 - (NSString *)capitalizedStringWithLocale:(NSLocale *)localeNS_AVAILABLE(10_8,6_0); //55.刪除字符串中包含字符集部分的字符 返回字符串 擴展一下,如果想要刪除字符串前後的空格或者回車,這樣做: [stringA stringByTrimmingCharactersInSet: [NSCharacterSetWhitespaceAndNewLineCharacterSet]]; - (NSString *)stringByTrimmingCharactersInSet:(NSCharacterSet *)set; //56.將字符串padString指定索引段添加到前面字符串後面 - (NSString *)stringByPaddingToLength:(NSUInteger)newLength withString:(NSString *)padString startingAtIndex:(NSUInteger)padIndex; //57.指定段分行去字符串 - (void)getLineStart:(NSUInteger *)startPtr end:(NSUInteger *)lineEndPtr contentsEnd:(NSUInteger *)contentsEndPtr forRange:(NSRange)range; //58.返回字符串指定段位置和長度 - (NSRange)lineRangeForRange:(NSRange)range; //59.給字符串指定段分段取字符串 - (void)getParagraphStart:(NSUInteger *)startPtr end:(NSUInteger *)parEndPtr contentsEnd:(NSUInteger *)contentsEndPtr forRange:(NSRange)range; //60指定段分段的位置和長度 - (NSRange)paragraphRangeForRange:(NSRange)range; //61. typedefNS_OPTIONS(NSUInteger, NSStringEnumerationOptions) { // Pass in one of the "By" options: NSStringEnumerationByLines =0, // Equivalent to lineRangeForRange: NSStringEnumerationByParagraphs =1, // Equivalent to paragraphRangeForRange: NSStringEnumerationByComposedCharacterSequences =2, // Equivalent to rangeOfComposedCharacterSequencesForRange: NSStringEnumerationByWords =3, NSStringEnumerationBySentences =4, // ...and combine any of the desired additional options: NSStringEnumerationReverse =1UL <<8, NSStringEnumerationSubstringNotRequired =1UL <<9, NSStringEnumerationLocalized =1UL <<10 // User's default locale }; //62.檢查是否在指定范圍內是否有匹配的字符串 - (void)enumerateSubstringsInRange:(NSRange)range options:(NSStringEnumerationOptions)opts usingBlock:(void (^)(NSString *substring,NSRange substringRange,NSRange enclosingRange, BOOL *stop))blockNS_AVAILABLE(10_6,4_0); //63.列舉枚舉字符串所有行 - (void)enumerateLinesUsingBlock:(void (^)(NSString *line,BOOL *stop))block NS_AVAILABLE(10_6,4_0); //64.字符串 @property (readonly,copy)NSString *description; //65.返回字符串哈希地址 @property (readonly)NSUInteger hash; /*** Encoding methods ***/ //66.字符串最快編碼值 @property (readonly)NSStringEncoding fastestEncoding; // //67.字符串最小編碼值 @property (readonly)NSStringEncoding smallestEncoding; // //68.返回指定編碼的NSData對象 - (NSData *)dataUsingEncoding:(NSStringEncoding)encoding allowLossyConversion:(BOOL)lossy; // External representation //69.返回指定編碼的NSData對象 - (NSData *)dataUsingEncoding:(NSStringEncoding)encoding; // External representation //70.判斷是否可以無損化轉碼 - (BOOL)canBeConvertedToEncoding:(NSStringEncoding)encoding; //71.char編碼轉化 - (__strongconstchar *)cStringUsingEncoding:(NSStringEncoding)encodingNS_RETURNS_INNER_POINTER; //72.C字符串轉化是夠成功 - (BOOL)getCString:(char *)buffer maxLength:(NSUInteger)maxBufferCount encoding:(NSStringEncoding)encoding;// NO return if conversion not //73.指定緩存區轉換 - (BOOL)getBytes:(void *)buffer maxLength:(NSUInteger)maxBufferCount usedLength:(NSUInteger *)usedBufferCount encoding:(NSStringEncoding)encoding options:(NSStringEncodingConversionOptions)options range:(NSRange)range remainingRange:(NSRangePointer)leftover; //74.字符串編碼時需要用的字節長度 - (NSUInteger)maximumLengthOfBytesUsingEncoding:(NSStringEncoding)enc; //75.字符串編碼時需要用到最大字節長度 - (NSUInteger)lengthOfBytesUsingEncoding:(NSStringEncoding)enc; //76.unicode范式D標准化 @property (readonly,copy)NSString *decomposedStringWithCanonicalMapping; //77.unicode范式c標准化 @property (readonly,copy)NSString *precomposedStringWithCanonicalMapping; //78.unicode范式KD標准化 @property (readonly,copy)NSString *decomposedStringWithCompatibilityMapping; //79.unicode范式KC標准化 @property (readonly,copy)NSString *precomposedStringWithCompatibilityMapping; //80.本地化字符串折疊 - (NSString *)stringByFoldingWithOptions:(NSStringCompareOptions)options locale:(NSLocale *)locale NS_AVAILABLE(10_5,2_0); //81.字符串的指定區域段被有條件的替換掉 - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(NSStringCompareOptions)options range:(NSRange)searchRangeNS_AVAILABLE(10_5,2_0); //82.字符串的特定字符串被替換掉 - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement NS_AVAILABLE(10_5,2_0); //83.將字符串的指定區域段字符串被替換掉 - (NSString *)stringByReplacingCharactersInRange:(NSRange)range withString:(NSString *)replacement NS_AVAILABLE(10_5,2_0); //84.將字符串轉化為char類型 @property (readonly)__strongconstchar *UTF8StringNS_RETURNS_INNER_POINTER; //85.默認C字符串編碼 + (NSStringEncoding)defaultCStringEncoding; //86.可用的字符串編碼 + (constNSStringEncoding *)availableStringEncodings; //87.編碼的名稱vheng + (NSString *)localizedNameOfStringEncoding:(NSStringEncoding)encoding; //88.指定緩沖區,編碼和字節長度初始化NSString對象 - (instancetype)initWithCharactersNoCopy:(unichar *)characters length:(NSUInteger)length freeWhenDone:(BOOL)freeBuffer; //89.指定unichar字符,字節長度初始化NSString對象 - (instancetype)initWithCharacters:(constunichar *)characters length:(NSUInteger)length; //90.轉化為NSString對象 - (instancetype)initWithUTF8String:(constchar *)nullTerminatedCString; //91.指定字符串初始化為NSString對象 - (instancetype)initWithString:(NSString *)aString; //92.格式化多個字符串初始化NSString對象 - (instancetype)initWithFormat:(NSString *)format, ...NS_FORMAT_FUNCTION(1,2); //93. 格式化字符串初始化NSString對象 - (instancetype)initWithFormat:(NSString *)format arguments:(va_list)argListNS_FORMAT_FUNCTION(1,0); //94.本地化格式化多個字符串初始化NSString對象 - (instancetype)initWithFormat:(NSString *)format locale:(id)locale, ...NS_FORMAT_FUNCTION(1,3); //95.本地化格式化字符串初始化NSString對象 - (instancetype)initWithFormat:(NSString *)format locale:(id)locale arguments:(va_list)argListNS_FORMAT_FUNCTION(1,0); //96.指定編碼轉化NSData數據 - (instancetype)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding; //97.指定編碼和字節數初始化NSString對象 - (instancetype)initWithBytes:(constvoid *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding; //98.指定緩沖區,編碼和字節數初始化NSString對象 - (instancetype)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer; //99.初始化空字符串 + (instancetype)string; //100.初始化NSString字符串 + (instancetype)stringWithString:(NSString *)string; //101.返回指定長度unichar的C字符串 + (instancetype)stringWithCharacters:(constunichar *)characters length:(NSUInteger)length; //102.轉化C字符串為UTF8串 + (instancetype)stringWithUTF8String:(constchar *)nullTerminatedCString; //103.初始化NSString對象昂,這種創建方式會自動釋放內存,很常用的一種方式 + (instancetype)stringWithFormat:(NSString *)format, ...NS_FORMAT_FUNCTION(1,2); //104.初始化NSString自動釋放內存,本地化 + (instancetype)localizedStringWithFormat:(NSString *)format, ...NS_FORMAT_FUNCTION(1,2); //105.初始化C字符串並且指定編碼,在這裡需要手動釋放內存(init) - (instancetype)initWithCString:(constchar *)nullTerminatedCString encoding:(NSStringEncoding)encoding; //106.初始化C字符串並且指定編碼,在這裡需要自動釋放內存 + (instancetype)stringWithCString:(constchar *)cString encoding:(NSStringEncoding)enc; //107.讀取URL地址數據轉化為字符串並且指定編碼,在這裡init創建需要手動釋放內存,已經知道編碼 - (instancetype)initWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error; //108.讀取FILE地址數據轉化為字符串並且指定編碼,同樣需要手動釋放內存,已經知道編碼 - (instancetype)initWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error; //109.讀取URL地址數據轉化為字符串並且指定編碼,,這裡會自動釋放內存,已經知道編碼 + (instancetype)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error; //110.讀取FILE地址數據轉化為字符串並且指定編碼,這裡也會自定釋放內存,已經知道編碼 + (instancetype)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error; //111.讀取URL地址數據轉化為字符串並且指定編碼,在這裡init創建需要手動釋放內存,不知道編碼 - (instancetype)initWithContentsOfURL:(NSURL *)url usedEncoding:(NSStringEncoding *)enc error:(NSError **)error; //112. 讀取FILE地址數據轉化為字符串並且指定編碼,同樣需要手動釋放內存,不知道編碼 - (instancetype)initWithContentsOfFile:(NSString *)path usedEncoding:(NSStringEncoding *)enc error:(NSError **)error; //113.取URL地址數據轉化為字符串並且指定編碼,,這裡會自動釋放內存,不知道編碼 + (instancetype)stringWithContentsOfURL:(NSURL *)url usedEncoding:(NSStringEncoding *)enc error:(NSError **)error; //114.讀取FILE地址數據轉化為字符串並且指定編碼,這裡也會自定釋放內存,不知道編碼 + (instancetype)stringWithContentsOfFile:(NSString *)path usedEncoding:(NSStringEncoding *)enc error:(NSError **)error; //115.將數據寫入URL並且指定編碼 - (BOOL)writeToURL:(NSURL *)url atomically:(BOOL)useAuxiliaryFile encoding:(NSStringEncoding)enc error:(NSError **)error; //116.將數據寫入文件並且指定編碼 - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile encoding:(NSStringEncoding)enc error:(NSError **)error; @end @interface NSMutableString :NSString //117.使用aString替換前面字符串的指定區域字符 - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString; @end //118.可變字符串的擴展方法 @interface NSMutableString (NSMutableStringExtensionMethods) //119.插入字符串aString,在指定的loc位置 - (void)insertString:(NSString *)aString atIndex:(NSUInteger)loc; //120.刪除指定區域段的字符串 - (void)deleteCharactersInRange:(NSRange)range; //121.追加字符串aString - (void)appendString:(NSString *)aString; //122.追加多個字符串 - (void)appendFormat:(NSString *)format, ...NS_FORMAT_FUNCTION(1,2); //123.設置新的aString - (void)setString:(NSString *)aString; //124.初始化一個容量為capacity大小的字符串,並且需要手動釋放內存 - (NSMutableString *)initWithCapacity:(NSUInteger)capacity; //125.初始化一個容量為capacity大小的字符串,但是不用手動釋放內存,這些提前指定的容量,知識用於內存優化,實際大小可以大於設置的容量capacity + (NSMutableString *)stringWithCapacity:(NSUInteger)capacity; //126.指定限制條件,指定區段中的replacement替換成target - (NSUInteger)replaceOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options: (NSStringCompareOptions)options range:(NSRange)searchRange; @end //128.關於字符串編碼檢測的擴展 @interface NSString (NSStringEncodingDetection) //129.對一份data數據進行轉換為字符串,有可選option字典,另外還有是否允許有損失,最終轉換之後返回一個編碼種類。下面是7種不同option字典選項 + (NSStringEncoding)stringEncodingForData:(NSData *)data encodingOptions:(NSDictionary *)opts convertedString:(NSString **)string usedLossyConversion:(BOOL *)usedLossyConversion NS_AVAILABLE(10_10, 8_0); @end FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionSuggestedEncodingsKeyNS_AVAILABLE(10_10,8_0); // NSArray of NSNumbers which contain NSStringEncoding values; if this key is not present in the dictionary, all encodings are considered FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionDisallowedEncodingsKeyNS_AVAILABLE(10_10,8_0); // NSNumber boolean value; if this key is not present in the dictionary, the default value is NO FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionUseOnlySuggestedEncodingsKeyNS_AVAILABLE(10_10,8_0); // NSNumber boolean value; if this key is not present in the dictionary, the default value is YES FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionAllowLossyKeyNS_AVAILABLE(10_10,8_0); // NSNumber boolean value; if this key is not present in the dictionary, the default value is NO FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionFromWindowsKeyNS_AVAILABLE(10_10,8_0); FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionLossySubstitutionKeyNS_AVAILABLE(10_10,8_0); FOUNDATION_EXPORTNSString *const NSStringEncodingDetectionLikelyLanguageKeyNS_AVAILABLE(10_10,8_0); @interface NSString (NSExtendedStringPropertyListParsing) //130.將字符串轉化為屬性列表 例如:NSString * stringA = [NSString stringWithFormat:@“Name =xulin ; age = 23;”]; NSLog(@“%@”,[stringA propertyList]); 控制台輸出為{ Name = xulin ; age = 23; } - (id)propertyList; //131.字符串轉化為字典 NSDictionary * dictionary = [stringA propertyListFromStringFileFormat]; NSLog(@“%@”,dictionary); 控制台輸出為{ Name = xulin ; age = 23; } - (NSDictionary *)propertyListFromStringsFileFormat @end //132.下面是一些棄用代碼。也就是上面所翻譯過的代碼。 @interface NSString (NSStringDeprecated) - (constchar *)cStringNS_RETURNS_INNER_POINTERNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (constchar *)lossyCStringNS_RETURNS_INNER_POINTER NS_DEPRECATED(10_0,10_4,2_0, 2_0); - (NSUInteger)cStringLengthNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (void)getCString:(char *)bytesNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (void)getCString:(char *)bytes maxLength:(NSUInteger)maxLengthNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (void)getCString:(char *)bytes maxLength:(NSUInteger)maxLength range:(NSRange)aRange remainingRange:(NSRangePointer)leftoverRange NS_DEPRECATED(10_0, 10_4, 2_0, 2_0); - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFileNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (BOOL)writeToURL:(NSURL *)url atomically:(BOOL)atomicallyNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (id)initWithContentsOfFile:(NSString *)pathNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (id)initWithContentsOfURL:(NSURL *)urlNS_DEPRECATED(10_0,10_4,2_0, 2_0); + (id)stringWithContentsOfFile:(NSString *)pathNS_DEPRECATED(10_0,10_4,2_0, 2_0); + (id)stringWithContentsOfURL:(NSURL *)urlNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (id)initWithCStringNoCopy:(char *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)freeBufferNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (id)initWithCString:(constchar *)bytes length:(NSUInteger)lengthNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (id)initWithCString:(constchar *)bytesNS_DEPRECATED(10_0,10_4,2_0, 2_0); + (id)stringWithCString:(constchar *)bytes length:(NSUInteger)lengthNS_DEPRECATED(10_0,10_4,2_0, 2_0); + (id)stringWithCString:(constchar *)bytesNS_DEPRECATED(10_0,10_4,2_0, 2_0); - (void)getCharacters:(unichar *)buffer; @end enum { NSProprietaryStringEncoding =65536 /* Installation-specific encoding */ }; #if !defined(_OBJC_UNICHAR_H_) #define _OBJC_UNICHAR_H_ #endif #define NS_UNICHAR_IS_EIGHT_BIT 0 @interface NSSimpleCString :NSString { @package char *bytes; int numBytes; #if __LP64__ int _unused; #endif } @end @interface NSConstantString :NSSimpleCString @end #if __LP64__ #else externvoid *_NSConstantStringClassReference; #endif