Normally I do something like this (below) to get value I need:
NSDictionary *state = [notification.userInfo objectForKey:@"state"];
[self.tabBarItem setBadgeValue:[state objectForKey:@"short"]];
But does it worth开发者_如何学C to do retain/release for values taken from NSDictionary? Something like this:
NSDictionary *state = [[notification.userInfo objectForKey:@"state"] retain];
[self.tabBarItem setBadgeValue:[state objectForKey:@"short"]];
[state release];
Is it more memory friendly? Or I shouldn't bother and just trust to autorelease pool to do its job?
No, there's no point in doing that. The result of [notification.userInfo objectForKey:@"state"]
is always an autoreleased object; if you add an extra retain
and release
, that won't change anything.
精彩评论