你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 基礎類解析 - NSString

iOS 基礎類解析 - NSString

編輯:IOS開發綜合

iOS 基礎類解析 - NSString

太陽火神的美麗人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商業用途-保持一致”創作公用協議

轉載請保留此句:太陽火神的美麗人生 - 本博客專注於 敏捷開發及移動和物聯設備研究:iOS、Android、Html5、Arduino、pcDuino,否則,出自本博客的文章拒絕轉載或再轉載,謝謝合作。



NSString 類參考
NSString Class Reference


繼承自
Inherits from NSObject 遵循的協議
Conforms to NSCopying
NSMutableCopying
NSSecureCoding
NSObject (NSObject)
所在框架
Framework /System/Library/Frameworks/Foundation.framework 可用於的 iOS 版本
Availability Available in iOS 2.0 and later. 聲明於頭文件
Declared in NSLinguisticTagger.h
NSPathUtilities.h
NSString.h
NSURL.h
配套的開發指南
Companion guides String Programming Guide
Property List Programming Guide
相關的示例代碼
Related sample code AdvancedURLConnections AirDrop Examples BonjourWeb MVCNetworking TableView Fundamentals for iOS

創建和初始化字符串
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 iOS 2.0
  • + stringWithCString:length: Deprecated in iOS 2.0
  • – initWithCString: Deprecated in iOS 2.0
  • – initWithCString:length: Deprecated in iOS 2.0
  • – initWithCStringNoCopy:length:freeWhenDone: Deprecated in iOS 2.0

    從一個文件創建和初始化字符串
    Creating and Initializing a String from a File

    • + stringWithContentsOfFile:encoding:error:
    • – initWithContentsOfFile:encoding:error:
    • + stringWithContentsOfFile:usedEncoding:error:
    • – initWithContentsOfFile:usedEncoding:error:
    • + stringWithContentsOfFile: Deprecated in iOS 2.0
    • – initWithContentsOfFile: Deprecated in iOS 2.0

      從一個 URL 創建和初始化字符串
      Creating and Initializing a String from an URL

      • + stringWithContentsOfURL:encoding:error:
      • – initWithContentsOfURL:encoding:error:
      • + stringWithContentsOfURL:usedEncoding:error:
      • – initWithContentsOfURL:usedEncoding:error:
      • + stringWithContentsOfURL: Deprecated in iOS 2.0
      • – initWithContentsOfURL: Deprecated in iOS 2.0

        將字符串內容寫到文件或 URL
        Writing to a File or URL

        • – writeToFile:atomically:encoding:error:
        • – writeToURL:atomically:encoding:error:
        • – writeToFile:atomically: Deprecated in iOS 2.0
        • – writeToURL:atomically: Deprecated in iOS 2.0

          獲取字符串長度
          Getting a String’s Length

          • – length
          • – lengthOfBytesUsingEncoding:
          • – maximumLengthOfBytesUsingEncoding:

            獲取字符和字節
            Getting Characters and Bytes

            • – characterAtIndex:
            • – getCharacters:range:
            • – getBytes:maxLength:usedLength:encoding:options:range:remainingRange:
            • – getCharacters: Deprecated in iOS 4.0

              獲取 C 字符串
              Getting C Strings

              • – cStringUsingEncoding:
              • – getCString:maxLength:encoding:
              • – UTF8String
              • – cString Deprecated in iOS 2.0
              • – cStringLength Deprecated in iOS 2.0
              • – getCString: Deprecated in iOS 2.0
              • – getCString:maxLength: Deprecated in iOS 2.0
              • – getCString:maxLength:range:remainingRange: Deprecated in iOS 2.0
              • – lossyCString Deprecated in iOS 2.0

                拼接字符串
                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

                          • – rangeOfComposedCharacterSequenceAtIndex:
                          • – rangeOfComposedCharacterSequencesForRange:

                            將字符串內容轉換成屬性列表
                            Converting String Contents Into a Property List

                            • – propertyList
                            • – propertyListFromStringsFileFormat

                              識別和比較字符串
                              Identifying and Comparing Strings

                              • – caseInsensitiveCompare:
                              • – localizedCaseInsensitiveCompare:
                              • – compare:
                              • – localizedCompare:
                              • – compare:options:
                              • – compare:options:range:
                              • – compare:options:range:locale:
                              • – localizedStandardCompare:
                              • – hasPrefix:
                              • – hasSuffix:
                              • – isEqualToString:
                              • – hash

                                拆疊字符串*
                                Folding Strings

                                • – stringByFoldingWithOptions:locale:

                                  獲取公共的前綴
                                  Getting a Shared Prefix

                                  • – commonPrefixWithString:options:

                                    改變大小寫
                                    Changing Case

                                    • – capitalizedString
                                    • – capitalizedStringWithLocale:
                                    • – lowercaseString
                                    • – lowercaseStringWithLocale:
                                    • – uppercaseString
                                    • – uppercaseStringWithLocale:

                                      使用映射獲取多個字符串*
                                      Getting Strings with Mapping

                                      • – decomposedStringWithCanonicalMapping
                                      • – decomposedStringWithCompatibilityMapping
                                      • – precomposedStringWithCanonicalMapping
                                      • – precomposedStringWithCompatibilityMapping

                                        獲取數字值
                                        Getting Numeric Values

                                        • – doubleValue
                                        • – floatValue
                                        • – intValue
                                        • – integerValue
                                        • – longLongValue
                                        • – boolValue

                                          處理字符編碼
                                          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:

                                              處理 URL
                                              Working with URLs

                                              • – stringByAddingPercentEscapesUsingEncoding:
                                              • – stringByReplacingPercentEscapesUsingEncoding:
                                              • – stringByAddingPercentEncodingWithAllowedCharacters:
                                              • – stringByRemovingPercentEncoding

                                                語言標記和分析*
                                                Linguistic Tagging and Analysis

                                                • – enumerateLinguisticTagsInRange:scheme:options:orthography:usingBlock:
                                                • – linguisticTagsInRange:scheme:options:orthography:tokenRanges:



                                                  Copyright ? 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2014-02-11









  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved