Possible Duplicate:
Where's the difference between setObject:forKey: and setValue:forKey: in NSMutableDictionary?
Hi,
setObject:forKey:
Adds a given key-value pair to the dictionary.
- (void)setObject:(id)开发者_开发问答anObject forKey:(id)aKey
Again
setValue:forKey:
Adds a given key-value pair to the dictionary.
- (void)setValue:(id)value forKey:(NSString *)key
Then what is the difference in between them? Is the difference only in receiving parameters? can setObject:forKey: be used instead of setValue:forKey: ?
From the doc:
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.
If aKey already exists in the dictionary, the dictionary’s previous value object for that key is sent a release message and anObject takes its place.
精彩评论