user1306602
user1306602

Reputation: 227

Strong property in ARC - Objective C

My question is simple but though I didn't found a precise answer on the net. Do I have to set to nil a strong property in viewDidUnload method ?

I know weak property will be automatically set to nil but what about strong property? Do I have to do this in viewDidUnload and also in didReceiveMemoryWarning ?

Thank you a lot! Teddy

Upvotes: 0

Views: 945

Answers (1)

lnafziger
lnafziger

Reputation: 25740

You should set it to nil in the "companion" function to where it is set, or where you want it to go away. For instance, if you set it in viewDidLoad you typically set it to nil in viewDidUnload. If you set it in viewWillAppear then set it to nil in viewWillDisappear.

Set it to nil in didReceiveMemoryWarning if it is something that you don't really need and can be recreated when you do need it next. (such as variables automatically created in their getter's).

Upvotes: 7

Related Questions