Abz Ios
Abz Ios

Reputation: 64

Managing View outlets in ios 5.0 and ios 6.0

I am working on an iPad application which is converted to ARC. Application is for os >= ios 5.0. So my doubt is that, how do I manage viewOutlets? I use -(void)didReceivememoryWarning to set ViewOutlets to nil. But in ios 5.0 and 5.1 application shows lots of memory leaks. As -(void)viewDidUnload is deprecated in ios 6.0 , I am not using the same in the application. Is the correct way to manage outlets? Please give me a quick reply.

Upvotes: 0

Views: 113

Answers (2)

Dipak Narigara
Dipak Narigara

Reputation: 1806

ARC (automatic reference counting) features is available in iOS 5 and ahead (iOS 6 and so on..) version.

When you are using ARC unable in your project, you dont need to `manually release any object` that you have allocated for your stuff.

ARC will automatic handle this one.so it will beneficial for `Memory Management`.


Hope ,You understand what i m trying to say.

for more clarification , please refer below link: To ARC or not to ARC? What are the pros and cons? ARC, worth it or not?

Good Luck !!!

Upvotes: 2

newacct
newacct

Reputation: 122429

There is NO DIFFERENCE in how you code for iOS 5 vs. iOS 6.

If you are having problems, it's because you don't understand what viewDidUnload does and when it's called.

viewDidUnload is called when the view of the controller is unloaded. In iOS 6, views are never unloaded. In iOS 5 and before, views were almost never unloaded either. So in both cases, pretty much viewDidUnload is never called.

If your program is leaking stuff, it's because you are not releasing things. You always need to release instance variables in dealloc. I suspect that this is your problem.

When the controller's view is unloaded (which only happens in iOS 5 and before, but this is irrelevant), viewDidUnload allows you to optionally discard some resources to save memory, as long as they are resources that will be re-created when the view is loaded again. This usually includes properties and instance variables that are outlets (since when the view is loaded, it will load the Xib again and re-connect the outlets to new objects), as well as any variables that are set in viewDidLoad.

If you coded your program correctly, I can go in there and remove viewDidUnload, and it would not have any effect on the correctness of the program. (Since viewDidUnload is almost never called anyway.)

You should almost never have to use didReceiveMemoryWarning either.

Upvotes: 0

Related Questions