[nsobject setValue:<#(id)#> forKey:<#(NSString *)#>]
[nsdictionary setObject:<#(id)#> forKey:<#(id<NSCopying>)#>];
set value for key 是改成员变量的值。值可以是nil 键必须是string
set object for key 是字典修改键值的方法。值为nil会crash 键可以为任意实现了nscopying协议的对象
问题:
可变字典的set value for key文档上说的实际上还是改的键值,不是成员变量值:
有值调用-setObject:forKey:
没值调用-removeObject:forKey:
那么可变字典怎样可以改成员变量的值?下面这个不明白怎么加前缀@??
in most cases. In other classes, setValue:forKey:
changes member variables. In NSMutableDictionary
, it changes dictionary entries, unless you prefix the key with a '@' character -- in which case it modifies member variables.