I can not understand this leak

SettingsView *settings = [[SettingsView alloc] initWithNibName:@"SettingsView" bundle:[NSBundle mainBundle]];
settings.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController presentModalViewController:settings animated:YES];
settings = nil;
[settings release];

Orders the next line to flow

[self.navigationController presentModalViewController:settings animated:YES];
+3
source share
2 answers

You need to let go settingsbefore setting it on nil, not after!

Now you do the same thing:

settings = nil;
[nil release];

Thus, -release is sent to nil, not to your object SettingsView. (And sending any message in nilis NOOP).

+15
source

Right Since the "settings" were never configured using @property and @synthesize, setting it to zero simply removes the memory address that it holds.

If you installed it using @property (nonatomic, retain) SettingsView *settings;

then later call settings = nil;

[settings release].

0

Source: https://habr.com/ru/post/1756021/


All Articles