开发者

Do I have to retain/release values taken from NSDictionary?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜