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 做交集运算 |