NSNumber常用方法總結
創建和初始化類的方法 |
初始化實例方法 |
檢索實例方法 |
numberWithChar: |
initWithChar: |
charValue |
numberWithUnsignedChar: |
initWithUnsignedChar: |
unsignedCharValue |
numberWithShort: |
initWithShort: |
shortValue |
numberWithUnsignedShort: |
initWithUnsignedShort: |
unsignedShortValue |
numberWithInteger: |
initWithInteger: |
integerValue |
numberWithUnsignedInteger: |
initWithUnsignedInteger: |
unsignedIntegerValue |
numberWithInt: |
initWithInt: |
intValueunsigned |
numberWithUnsignedInt: |
initWithUnsignedInt: |
unsignedIntValue |
numberWithLong: |
initWithLong: |
longValue |
numberWithUnsignedLong: |
initWithUnsignedLong: |
unsignedLongValue |
numberWithLongLong: |
initWithLongLong: |
longlongValue |
numberWithUnsignedLongLong: |
initWithUnsignedLongLong: |
unsignedLongLongValue |
numberWithFloat: |
initWithFloat: |
floatValue |
numberWithDouble: |
initWithDouble: |
doubleValue |
numberWithBool: |
initWithBool: |
boolValue |
NSSring常用方法總結
+(id)stringWithContentsOfFile:path encoding:enc err |
創建一個新字符串並將其設置爲 path 指定文件的內容,使用字符編碼 enc,在err 上返回錯誤 |
+(id)stringWithContentsOfURL:url encoding:enc err |
創建一個新字符串並將其設置爲 url 所指向的內容,使用字符編碼 enc,在err 上返回錯誤 |
+(id)string |
創建一個新的空字符串 |
+(id)stringWithString:nsstring |
創建一個新字符串,將其內容設置爲 nsstring 內容 |
-(id)initWithString:nsstring |
將字符串內容設置爲 nsstring 內容 |
-(id)initWithContentsOfFile:path encoding:enc error:err |
將字符串設置爲 path 指定文件的內容,使用字符編碼 enc,在err 上返回錯誤 |
-(id)initWithContentsOfURL:url encoding:enc error:err |
將字符串設置爲 url 所指向的內容,使用字符編碼 enc,在err 上返回錯誤 |
-(UNSigned int)length |
返回字符串中字符數目 |
-(unichar)characterAtindex:i |
返回索引i 所在UniCode 字符 |
-(NSString*)substringFromIndex:i |
返回從索引 i 開始到結尾的子字符串 |
-(NSString*)substringWithRange:range |
根據指定範圍返回子字符串 |
-(NSString*)substringToIndex:i |
返回從字符串開始到 索引 i 的子字符串 |
-(NSComparator*)caseInsensitiveCompare:nsstring |
比較兩個字符串大小,忽略大小寫 |
-(NSComparator*)compare:nsstring |
比較兩個字符串大小 |
-(BOOL)hasPrefix:nsstring |
測試字符串是否以 nsstring 開始 |
-(BOOL)hasSuffix:nsstring |
測試字符串是否以 nsstring 結尾 |
-(BOOL)isEqualToString:nsstring |
測試兩個字符串是否相等 |
-(NSString*)capitalizedString |
返回字符串,串中的每個單詞的首字母大寫,其餘字母小寫 |
-(NSString*)lowercaseString |
返回轉換爲小寫的字符串 |
-(NSString*)uppercaseString |
返回轉換爲大寫的字符串 |
-(const char*)UTF8String |
返回UTF8編碼格式的字符串 |
-(double)doubleValue |
返回轉換爲double 類型的字符串 |
-(float)floatValue |
返回轉換爲 float 類型的字符串 |
-(NSInteger)integerValue |
返回轉換爲 NSInteger 類型的新字符串 |
-(int)intvalue |
返回轉換爲 int 的字符串 |
NSMutableString 常用方法總結
+(id)stringWithCapacity:size |
創建一個字符串,容量爲size大小 |
-(id)initWithCapacity:size |
初始化一個字符串,容量爲size |
-(void)setString:nsstring |
將字符串設置爲 nsstring |
-(void)appendString:nsstring |
在字符串末尾追加字符串 nsstring |
-(void)deleteCharatersInRange:range |
刪除指定range 中的字符 |
-(void)insertString:nsstring atIndex:i |
以索引 i 爲起始位置插入 nsstring |
-(void)replaceCharatersInRange;range withString:nsstring |
使用 nsstring 替換 range 指定的字符 |
-(void)replaceOccurrencesOfString:nsstring withString:nsstring2 options:opts range:range |
根據選項 opts ,使用指定 range 中的nsstring2 替換所有的 nsstring |
NSArray常用方法總結
+ (id)arrayWithObjects:(id)firstObj, …nil |
創建一個新數組, 逗號隔開,nil結尾. |
- (BOOL)containsObject:(id)anObject |
確定數組中是否包含對象anObject(是用isEqual方法) |
-(NSUInteger)count |
數組中元素的個數 |
- (NSUInteger)indexOfObject:(id)anObject |
第一個包含anObject的元素索引號(使用isEqual方法) |
- (id)objectAtIndex:(NSUInteger)index |
存儲在元素index的對象 |
-(void)makeObjectsPerformSelector:(SEL)aSelector |
將aSelector指示的消息發送給數組中的每個元素 |
-(NSArray *)sortedArrayUsingSelector:(SEL)comparator |
根據comparator指定的方法進行排序 |
-(BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag |
將數組寫入指定的文件中,如果flag爲YES,那麼應該先創建一個臨時文件. |
NSMutableArray常用方法總結
+(id) array |
創建一個空數組(無需手動釋放) |
+ (id)arrayWithCapacity:(NSUInteger)size |
使用指定的初始size創建一個數組 |
- (id)initWithCapacity:(NSUInteger)size |
使用指定的初始size初始化新分配的數組 |
- (void)addObject:(id)anObject |
將對象anObject添加到數組的末尾 |
-(void)insertObject:(id)anObject atIndex:(NSUInteger) index |
將對象anObject插入數組的index元素 |
-(void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject |
將數組中序號爲index的對象用anObject替換 |
- (void)removeObjectAtIndex:(NSUInteger)index |
從數組中刪除元素index,將序號爲index+1的對象移至數組的結尾 |
- (void)removeObject:(id)anObject |
從數組中刪除所有anObject |
- (void)sortUsingSelector:(SEL)comparator |
用comparator指示的比較方法將組排序 |
NSDictionary 常用方法總結
+(id)dictionaryWithObjectsAndKeys:obj1,key1,obj2,key2,......nil |
順序添加對象和鍵值來創建一個字典,注意結尾是nil |
-(id)initWithObjectsAndKeys::obj1,key1,obj2,key2,......nil |
初始化一個新分配的字典,順序添加對象和值,結尾是nil |
-(unsigned int)count |
返回字典中的記錄數 |
-(NSEnumerator*)keyNSEnumerator |
返回字典中的所有鍵到一個 NSEnumerator 對象 |
-(NSArray*)keysSortedByValueUsingSelector:(SEL)selector |
將字典中所有鍵按照selector 指定的方法進行排序,並將結果返回 |
-(NSEnumerator*)objectEnumerator |
返回字典中所有的值到一個 NSEnumetator 類型對象 |
-(id)objectForKey:key |
返回指定key 值的對象 |
NSMutableDictionary 常用方法總結
+(id)dictionaryWithCapacity:size |
創建一個size大小的可變字典 |
-(id)initWithCapacity:size |
初始化一個size 大小的可變字典 |
-(void)removeAllObjects |
刪除字典中所有元素 |
-(void)removeObjectForKey:key |
刪除字典中key位置的元素 |
-(void)setObject:obj forKey:key |
添加 (key , obj)到字典中去;若key已經存在,則替換值爲 obj |
NSSet 常用方法總結
+(id)setWithObjects:obj1,obj2,...nil |
使用一組對象創建新的集合 |
-(id)initWithObjects:obj1,obj2,....nil |
使用一組對象初始化新分配的集合 |
-(NSUInteger)count |
返回集合成員個數 |
-(BOOL)containsObject:obj |
確定集合是否包含對象 obj |
-(BOOL)member:obj |
確定集合是否包含對象 obj |
-(NSEnumerator*)objectEnumerator |
返回集合中所有對象到一個 NSEnumerator 類型的對象 |
-(BOOL)isSubsetOfSet:nsset |
判斷集合是否是 nsset 的子集 |
-(BOOL)intersectsSet:nsset |
判斷兩個集合的交集是否至少存在一個元素 |
-(BOOL)isEqualToSet:nsset |
判斷兩個集合是否相等 |
NSMutableSet 常用方法總結
-(id)setWithCapcity:size |
創建一個有size大小的新集合 |
-(id)initWithCapcity:size |
初始化一個新分配的集合,大小爲size |
-(void)addObject:obj |
添加對象 obj 到集合中 |
-(void)removeobject:obj |
從集合中刪除對象 obj |
-(void)removeAllObjects |
刪除集合中所有對象 |
-(void)unionSet:nsset |
將nsset的所有元素添加到集合 |
-(void)minusSet:nsset |
從集合中去掉所有的nsset 的元素 |
-(void)interectSet:nsset |
集合和nsset 做交集運算 |