user792459
user792459

Reputation:

Dismissing a modal view causes the app crash

I'm displaying a modal view called "rule" from a round rect button. In that "rule" modal view i'm displaying another modal view called "newRule" when user clicks the Create Rule button. When i'm quitting from the "newRule" modal view the app crashes. Here's the code i had written for quitting the "newRule" modal view.

     [self dismissModalViewControllerAnimated:YES];

Nothing is displayed in the console. When i tried to debug the code, it displayed a EXC_BAD_ACCESS after the dealloc method. My dealloc method looks like this:

    [label release];
    label = nil;

    [imageArray release];
    imageArray = nil;

    [languageElementsArray release];
    languageElementsArray = nil;
    [super dealloc];

Please help me.

Upvotes: 0

Views: 426

Answers (3)

DanZimm
DanZimm

Reputation: 2568

Is the label a UILabel object? Also what are in the arrays? Views are automatically released once their superview is released, so releasing a subview after its superview has been released (or releasing the subview then the superview) will cause an crash similar to the one you describe

Upvotes: 1

Duncan Babbage
Duncan Babbage

Reputation: 20177

If you happen to be using Automatic Reference Counting in Xcode 4.2, then you should not have a [super dealloc] at all—which would result in this error.

Of course, in that context you likely should not be releasing these other objects either.

Upvotes: 0

gordon
gordon

Reputation: 1

I'm experiencing something similar. When I comment out the last line ( [super dealloc] ), it then works. Does this make a difference for you?

Upvotes: 0

Related Questions