标签:style blog http io os 使用 ar for art
Foundation 框架:
NSString *myString = @"My String\n";
NSString *anotherString = [NSString stringWithFormat:@"%d %@", 1, @"String"];
NSString *fromCString = [NSString stringWithCString:"A C string" encoding:NSUTF8StringEncoding];
NSString *string = [NSString string]; NSString
类声明 string
类方法 ?
NSNumber
NSNumber *myIntValue = @32;
NSNumber *myDoubleValue = @3.22346432;
NSNumber *myBoolValue = @YES;
NSNumber *myCharValue = @‘V‘;
NSNumber *myFloatValue = @3.2F
NSArray
、NSSet
和 NSDictionary
类的内容不能随时间而变化。定义:
NSArray *someArray = @[firstObject, secondObject, thirdObject];(不要用nil结尾)
NSArray *someArray =
[NSArray arrayWithObjects:firstObject, secondObject, thirdObject, nil];(以nil作为结尾符,与c中的char数组类似)NSArray *sortedStrings =
[unsortedStrings sortedArrayUsingSelector:@selector(compare:)]; (由于NSArray不可变,所以该方法会返回新的排好序的数组)NSMutableString *mutableString = [NSMutableString stringWithString:@"Hello"];
NSMutableArray *mutableArray = [NSMutableArray array];
[mutableArray addObject:@"gamma"];
[mutableArray replaceObjectAtIndex:0 withObject:@"epsilon"];
或者 mutableArray[0] = @"epsilon";[mutableArray sortUsingSelector:@selector(caseInsensitiveCompare:)];
NSSet *simpleSet =
[NSSet setWithObjects:@"Hello, World!", @42, aValue, anObject, nil];
NSNumber *storedNumber = dictionary[@"magicNumber"];
或者 NSNumber *storedNumber = [dictionary objectForKey:@"magicNumber"];NSMutableDictionary
子类?NSCopying
。不过,如果要使用键-值编码,则必须为字典对象使用字符串键。若要了解更多信息,请参阅《Key-Value Coding Programming Guide》(键值编码编程指南)。)NSArray *array = @[ @"string", @42, [NSNull null] ];
标签:style blog http io os 使用 ar for art
原文地址:http://www.cnblogs.com/monmonde/p/3972211.html