I want to assign a object to NSMutableDictionary in one method and want to use it in another method as below:
- (void) aaa {
NSString* aa = @"hello";
[self.pcs setObject:aa forKey:@"a"];
}
- (void) bbb {
NSLog(@"ccc %@", self.pcs[@"a"]);
}
pcs is a property in @interface
@property(nonatomic, copy) NSMutableDictionary* pcs;
if I call aaa
and bbb
in another method, I want method bbb
to print the log of ccc hello
, but the result is ccc (null)
Can anybody tell me how to store object in NSMuableDictionary?
How did you initialise self.pcs?
If self.pcs is null, of course self.pcs[@"a"] is null