开发者

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

开发者 https://www.devze.com 2023-03-30 01:53 出处:网络
Normally I do something like this (below) to get value I need: NSDictionary *state = [notification.userInfo objectForKey:@\"state\"];

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

精彩评论

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