xcode - iOS memory management with ARC -


let's i'm working on app large number of views , have problems understanding memory management when uiviewcontroller segues uiviewcontroller.

which of following object should release in viewdiddisappear: ?

@property (weak, nonatomic) iboutlet uiimageview *background;  @property (strong,nonatomic) uilabel *playerlevel;  - (void)viewdidload {     [super viewdidload];      map = [[mapview alloc]init];     [self.view addsubview:map]; } 

is correct way ?

- (void)viewdiddisappear:(bool)animated {     [super viewdiddisappear:yes];      [_background removefromsupeview];     [self.playerlevel removefromsupeview];     [map removefromsupeview];      _background = nil;     self.playerlevel = nil;     map = nil; } 

you don't need anything. arc implement dealloc method you, call releases retained properties.

i recommend read memory management documentation apple, understand arc doing, including understanding how retain cycles can avoided.

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/memorymgmt/articles/mmrules.html


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -