字符串方法
獲取字符串長度@property (readonly) NSUInteger length;
獲取字符串中的字符- (unichar)characterAtIndex:(NSUInteger)index;
判斷兩個字符串是否相等- (BOOL)isEqualToString:(NSString *)aString;
字符串的比較- (NSComparisonResult)compare:(NSString *)string;
獲取子字符串從下標num至最后- (NSString *)substringFromIndex:(NSUInteger)from;
獲取子字符串從起始至下標num之前- (NSString *)substringToIndex:(NSUInteger)to;
獲取子字符串于Range范圍內- (NSString *)substringWithRange:(NSRange)range;
字符串拼接- (NSString *)stringByAppendingString:(NSString *)aString;
字符串替換- (NSString *)stringByReplacingCharactersInRange:(NSRange)range withString:(NSString *)replacement NS_AVAILABLE(10_5, 2_0);
字符串轉為其他基本類型@property (readonly) double doubleValue;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?@property (readonly) float floatValue;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?@property (readonly) int intValue;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?@property (readonly) NSInteger integerValue NS_AVAILABLE(10_5, 2_0);
字母大小寫控制@property (readonly, copy) NSString *uppercaseString;
? ? ? ? ? ? ? ? ? ? ? @property (readonly, copy) NSString *lowercaseString;
? ? ? ? ? ? ? ? ? ? ? @property (readonly, copy) NSString *capitalizedString;
判斷是否以某個字符串開頭/結尾- (BOOL)hasPrefix:(NSString *)str;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? - (BOOL)hasSuffix:(NSString *)str;
可變字符串方法
可變字符串拼接- (void)appendString:(NSString *)aString;
? ? ? ? ? ? ? ? ? ? ? - (void)appendFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
可變字符串插入- (void)insertString:(NSString *)aString atIndex:(NSUInteger)loc;
刪除字符串- (void)deleteCharactersInRange:(NSRange)range;
替換字符串- (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString;
重置可變字符串- (void)setString:(NSString *)aString;
數(shù)組方法
元素個數(shù)@property (readonly) NSUInteger count;
獲取數(shù)組中指定下標對應的元素- (ObjectType)objectAtIndex:(NSUInteger)index;
檢測數(shù)組中是否包含某個對象- (BOOL)containsObject:(ObjectType)anObject;
獲取數(shù)組某個元素對應的下標- (NSUInteger)indexOfObject:(ObjectType)anObject;
將字符串按一定的規(guī)律分割,并得到一個數(shù)組- (NSArray*)componentsSeparatedByString:(NSString *)separator;
將數(shù)組元素按照給定字符串穿插成字符串- (NSString *)componentsJoinedByString:(NSString *)separator;
可變數(shù)組方法
向數(shù)組添加一個對象(默認添加至最后)- (void)addObject:(ObjectType)anObject;
向數(shù)組指定位置添加對象- (void)insertObject:(ObjectType)anObject atIndex:(NSUInteger)index;
移除元素- (void)removeObjectAtIndex:(NSUInteger)index;
? ? ? ? ? ? ?- (void)removeLastObject;
? ? ? ? ? ? ?- (void)removeAllObjects;
替換指定下標的元素- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(ObjectType)anObject;
交換兩個下標指定的對象- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
字典方法
獲取字典中鍵值對個數(shù)@property (readonly) NSUInteger count;
獲取所有的鍵@property (readonly, copy) NSArray*allKeys;
獲取所有的值@property (readonly, copy) NSArray*allValues;
獲取指定key所對應的value - (nullable ObjectType)objectForKey:(KeyType)aKey;
可變字典方法
根據(jù)key值修改value,并且如果字典沒有這個key那就會自動添加一個鍵值對
- (void)setObject:(ObjectType)anObject forKey:(KeyType)aKey;
移除指定key對應的鍵值對- (void)removeObjectForKey:(KeyType)aKey;
移除所有鍵值對(清空字典)- (void)removeAllObjects;
集合方法
獲取集合中元素的個數(shù)@property (readonly) NSUInteger count;
獲取集合中所有對象@property (readonly, copy) NSArray*allObjects;
隨機獲取集合中一個元素- (nullable ObjectType)anyObject;
檢測集合中是否包含某個對象(是1否0)- (BOOL)containsObject:(ObjectType)anObject;
可變集合方法
添加一個對象- (void)addObject:(ObjectType)object;
移除一個對象- (void)removeObject:(ObjectType)object;
移除所有元素- (void)removeAllObjects;