NSNumber
[NSNumber numberWithInt:666] 等价于 @666
[NSNumber numberWithLongLong:666ll] 等价于 @666ll
[NSNumber numberWithUnsignedLong:666ul] 等价于 @666ul
[NSNumber numberWithFloat:66.6f] 等价于 @66.6f
[NSNumber numberWithDouble:66.6] 等价于 @66.6
[NSNumber numberWithBool:YES] 等价于 @YES
[NSNumber numberWithChar:‘A’] 等价于 @‘A’
NSArray
[NSArray array] 等价于 @[]
[NSArray arrayWithObject:a] 等价于 @[a]
[NSArray arrayWithObjects:a, b, c, nil] 等价于 @[a,b,c]
[arr objectAtIndex:i] 等价于 arr[i];
[arr replaceObjectAtIndex:i withObject:newObj]
等价于 arr[i] = newObj
NSMutableArray * mutableArr = [@[a,b,c] mutableCopy];
NSDictionary
[NSDictionary dictionary] 等价于 @{}
[NSDictionary dictionaryWithObject:obj1 forKey:key1]
等价于 @{key1:obj1}
[NSDictionary dictionaryWithObjectsAndKeys:obj1, key1, obj2, key2, obj3, key3, nil]
等价于 @{key1:obj1,key2:obj2,key3:obj3}
[dic objectForKey:key] 等价于 dic[key]
[dic setObject:obj forKey:key] 等价于 dic[key] = obj
NSMutableDictionary * mutableDic = [@{key1:obj1} mutableCopy];
时间: 2024-10-24 20:40:19