NSDictionry

2018-12-06  本文已影响11人  乐乐的熊

https://blog.csdn.net/itianyi/article/details/8661997

1.setValue和setObject的区别

1>使用

1.2者都是为可变字典赋值

setObject:是字典特有的方法
key不仅仅是字符串,是id类型

@interface NSMutableDictionary(NSKeyValueCoding)

/* Send -setObject:forKey: to the receiver, unless the value is nil, in which case send -removeObject:forKey:.

*/

- (void)setValue:(id)value forKey:(NSString *)key;

@end

@interface NSMutableDictionary :NSDictionary

- (void)removeObjectForKey:(id)aKey;

- (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;

@end

2 简写

NSDictionary *dic = @{@"value1":@"key1",@"value2":@"key2"};

3 枚举不可放字典中

上一篇下一篇

猜你喜欢

热点阅读