Possible Duplicate:
How to add to an NSDictionary
When I do that :
NSDictionary *dic = [NSDictionary dictionary];
[dic setValue:@"nvjd" forKey:@"name"];
my app just crash. I don’t understand why. How should I add a string in a dictionary ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to make your dictionary mutable, otherwise it would not respond to the
setValue:forKey:selector:This is a common pattern in cocoa: you often see classes declared in pairs:
NSArray/NSMutableArray,NSSet/NSMutableSet,NSString/NSMutableString, and so on. Mutable version is capable of doing everything that the immutable version can do, but it also supports operations that change its content.