Creating and Initializing Strings
+ string– init– initWithBytes:length:encoding:– initWithBytesNoCopy:length:encoding:freeWhenDone:– initWithCharacters:length:– initWithCharactersNoCopy:length:freeWhenDone:– initWithString:– initWithCString:encoding:– initWithUTF8String:– initWithFormat:– initWithFormat:arguments:– initWithFormat:locale:– initWithFormat:locale:arguments:– initWithData:encoding:+ stringWithFormat:+ localizedStringWithFormat:+ stringWithCharacters:length:+ stringWithString:+ stringWithCString:encoding:+ stringWithUTF8String:+ stringWithCString:Deprecated in OS X v10.4+ stringWithCString:length:Deprecated in OS X v10.4– initWithCString:Deprecated in OS X v10.4– initWithCString:length:Deprecated in OS X v10.4– initWithCStringNoCopy:length:freeWhenDone:Deprecated in OS X v10.4
Creating and Initializing a String from a File
+ stringWithContentsOfFile:encoding:error:– initWithContentsOfFile:encoding:error:+ stringWithContentsOfFile:usedEncoding:error:– initWithContentsOfFile:usedEncoding:error:+ stringWithContentsOfFile:Deprecated in OS X v10.4– initWithContentsOfFile:Deprecated in OS X v10.4
Creating and Initializing a String from an URL
+ stringWithContentsOfURL:encoding:error:– initWithContentsOfURL:encoding:error:+ stringWithContentsOfURL:usedEncoding:error:– initWithContentsOfURL:usedEncoding:error:+ stringWithContentsOfURL:Deprecated in OS X v10.4– initWithContentsOfURL:Deprecated in OS X v10.4
Writing to a File or URL
– writeToFile:atomically:encoding:error:– writeToURL:atomically:encoding:error:– writeToFile:atomically:Deprecated in OS X v10.4– writeToURL:atomically:Deprecated in OS X v10.4
Getting a String’s Length
Getting Characters and Bytes
– characterAtIndex:– getCharacters:range:– getBytes:maxLength:usedLength:encoding:options:range:remainingRange:– getCharacters:Deprecated in OS X v10.6
Getting C Strings
– cStringUsingEncoding:– getCString:maxLength:encoding:– UTF8String– cStringDeprecated in OS X v10.4– cStringLengthDeprecated in OS X v10.4– getCString:Deprecated in OS X v10.4– getCString:maxLength:Deprecated in OS X v10.4– getCString:maxLength:range:remainingRange:Deprecated in OS X v10.4– lossyCStringDeprecated in OS X v10.4
Combining Strings --字符串拼接
– stringByAppendingFormat:– stringByAppendingString:– stringByPaddingToLength:withString:startingAtIndex:
Dividing Strings --字符串分割
– componentsSeparatedByString:--字符串转换成数组– componentsSeparatedByCharactersInSet:– stringByTrimmingCharactersInSet:– substringFromIndex:--从。。。截取字符串– substringWithRange: --从。。。开始截取多长的字符串– substringToIndex: --截取到。。。字符串
Finding Characters and Substrings --查找字符串
– rangeOfCharacterFromSet:– rangeOfCharacterFromSet:options:– rangeOfCharacterFromSet:options:range:– rangeOfString:--查找字符串– rangeOfString:options:– rangeOfString:options:range:– rangeOfString:options:range:locale:– enumerateLinesUsingBlock:– enumerateSubstringsInRange:options:usingBlock:
Replacing Substrings
– stringByReplacingOccurrencesOfString:withString:– stringByReplacingOccurrencesOfString:withString:options:range:– stringByReplacingCharactersInRange:withString:
Determining Line and Paragraph Ranges
– getLineStart:end:contentsEnd:forRange:– lineRangeForRange:– getParagraphStart:end:contentsEnd:forRange:– paragraphRangeForRange:
Determining Composed Character Sequences
Converting String Contents Into a Property List
Identifying and Comparing Strings
– caseInsensitiveCompare: 比较字符串大小– localizedCaseInsensitiveCompare:– compare:– localizedCompare:– compare:options:– compare:options:range:– compare:options:range:locale:– localizedStandardCompare:– hasPrefix:– hasSuffix:– isEqualToString: 比较字符串内容– hash
Folding Strings
Getting a Shared Prefix
Changing Case
– capitalizedString– capitalizedStringWithLocale:– lowercaseString 全部小写– lowercaseStringWithLocale:– uppercaseString 全部大写– uppercaseStringWithLocale:
Getting Strings with Mapping
– decomposedStringWithCanonicalMapping– decomposedStringWithCompatibilityMapping– precomposedStringWithCanonicalMapping– precomposedStringWithCompatibilityMapping
Getting Numeric Values
Working with Encodings
+ availableStringEncodings+ defaultCStringEncoding+ localizedNameOfStringEncoding:– canBeConvertedToEncoding:– dataUsingEncoding:– dataUsingEncoding:allowLossyConversion:– description– fastestEncoding– smallestEncoding
Working with Paths
+ pathWithComponents:– pathComponents– completePathIntoString:caseSensitive:matchesIntoArray:filterTypes:– fileSystemRepresentation– getFileSystemRepresentation:maxLength:– isAbsolutePath– lastPathComponent– pathExtension– stringByAbbreviatingWithTildeInPath– stringByAppendingPathComponent:– stringByAppendingPathExtension:– stringByDeletingLastPathComponent– stringByDeletingPathExtension– stringByExpandingTildeInPath– stringByResolvingSymlinksInPath– stringByStandardizingPath– stringsByAppendingPaths:
Working with URLs
– stringByAddingPercentEscapesUsingEncoding:– stringByReplacingPercentEscapesUsingEncoding:– stringByAddingPercentEncodingWithAllowedCharacters:– stringByRemovingPercentEncoding
Linguistic Tagging and Analysis
– enumerateLinguisticTagsInRange:scheme:options:orthography:usingBlock:– linguisticTagsInRange:scheme:options:orthography:tokenRanges:
NSMutableString
Creating and Initializing a Mutable String
Modifying a String
– appendFormat:– appendString:– deleteCharactersInRange:– insertString:atIndex:– replaceCharactersInRange:withString:– replaceOccurrencesOfString:withString:options:range:– setString:
字符串操作指南
本文详细介绍了字符串的各种操作方法,包括创建、初始化、拼接、分割、查找等,并提供了修改字符串的具体方式,适合各阶段开发者参考。
2559

被折叠的 条评论
为什么被折叠?



