这个问题在这里已经有了答案:
Best Answer-推荐答案 strong>
来自文档:
setValue:forKey:
Discussion
This method adds value and key to the dictionary using setObject:forKey:, unless value is nil in which case the method instead attempts to remove key using removeObjectForKey:.
setObject:forKey:
Important
Raises an NSInvalidArgumentException if aKey or anObject is nil. If you need to represent a nil value in the dictionary, use NSNull.
如果字典中已经存在aKey,则向字典的该键的先前值对象发送一条释放消息,并用一个对象代替它。
关于iphone: setObject:forKey: 和 setValue:forKey: 在将条目添加到可变字典中有什么区别,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/6161492/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) |
Powered by Discuz! X3.4 |