Memory error due to [super dealloc] uiview controller

I have an instance uiviewcontroller, and when I release it, the dealloc method is called.

I have released several objects in the dealloc method of this uiviewcontroller.

If I comment [super dealloc], the application works fine, but if it doesn't work.

I think there is no problem with the releases that I make in this method, but if I do [super dealloc], it crashes.

Can anyone help me with this?

+3
source share
3 answers

It's hard to say from your post without further information, but what does your dealloc method look like?

- (void)dealloc {

    [super dealloc];

    self.someProperty = nil;
}

, , setter . [super dealloc] :

- (void)dealloc {

    self.someProperty = nil;

    [super dealloc];

}

, . , dealloc, . .

+4

. , , . - .

, , [super dealloc], , .

+1

, . , [super dealloc] ViewController.m

[releaseController release], , . , , , . , , . ApplicationDelegate - , :

- (void)applicationDidFinishLaunching:(UIApplication *)application {
UIViewController *controller = [[UIViewController alloc] init];
[window addSubview:controller.view];
[controller release]; //this will crash
}

(.h) dealloc:

- (void)dealloc {
[controller release];
[window release];
[super dealloc];
}

, .

0

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


All Articles