setValue和setObject的区别
来源:互联网 发布:php入门很简单 pdf 编辑:程序博客网 时间:2024/05/02 06:11
1 setValue: forKey:的定义
@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
value 为 nil ,调用 removeObject:forKey:
value不为nil时调用 setObject:forKey:
key为NSString类型。
2 setObject:forKey:的定义
@interface NSMutableDictionary : NSDictionary
- (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;
@end
anobject不能为nil,而且key是一个id类型,不仅限于NSString类型
两者的区别:
(1)setObject:forkey:中value是不能够为nil的;setValue:forKey:中value能够为nil,但是当value为nil的时候,会自动调用removeObject:forKey方法
(2)setValue:forKey:中key只能够是NSString类型,而setObject:forKey:的可以是任何类型
@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
value 为 nil ,调用 removeObject:forKey:
value不为nil时调用 setObject:forKey:
key为NSString类型。
2 setObject:forKey:的定义
@interface NSMutableDictionary : NSDictionary
- (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;
@end
anobject不能为nil,而且key是一个id类型,不仅限于NSString类型
两者的区别:
(1)setObject:forkey:中value是不能够为nil的;setValue:forKey:中value能够为nil,但是当value为nil的时候,会自动调用removeObject:forKey方法
(2)setValue:forKey:中key只能够是NSString类型,而setObject:forKey:的可以是任何类型
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue 和 setObject 的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- setValue和setObject的区别
- 解读PTR_ERR,ERR_PTR,IS_ERR
- Notepad++设置双窗口模式
- 目所需的应用程序未安装,确保已安装项目类型(.csproj)的应用程序
- 深度理解Oracle10g中UNDO_RETENTION参数的使用 .
- 研究生期间工作
- setValue和setObject的区别
- 简单科研思路
- 查出生月份,看宝宝健康
- 六大视频网站播放清晰度比较
- C++拷贝构造函数(深拷贝,浅拷贝)
- 2011年上学年河北金融学院CSDN高校俱乐部学术活动总结
- redhat 5安装 oracle 10g
- 浅谈LWIP对齐问题
- android 手机设备唯一标识