- (void) msg:(NSString *)msg from:(NSString *)from
{
NSMutableDictionary *m = [[NSMutableDictionary alloc] init];
[m setObject:msg forKey:@"msg"];
[m setObject:from forKey:@"sender"];
[m setObject:[NSString getCurrentTime] forKey:@"time"];
NSLog(@"MSG=>%@ : FROM=>%@ : TIME=>%@",[m objectForKey:msg], [m objectForKey:@"sender"], [m objectForKey:@"time"]);
NSLog(@"MSG=>%@",msg);
}
Reply of first log is
MSG=>(null) : FROM=>your friend! : TIME=>Apr 30, 2012 12:52:02 AM
And reply of second log is
MSG=>hello…how are you
I didn’t understand why “msg” after going inside NSMutableDictionary getting null? after all parameter “from” is also displaying fine. And the interesting thing is logging msg parameter directly displaying perfectly.
I am using ARC enabled project and getting this null issue. I don’t want to declare NSMutableDictionary out side of this method because it is getting called many times and every time new NSMutableDictionary created and stored in NSArray for further use.
is wrong, you’re trying to get back the object using itself as the key. Correctly: