Jonathan.
Jonathan.

Reputation: 55534

Uialertview and memory management

If I alloc unit a UIAlertview and then show it. Should I release it after the show or should I autorelease it?

Upvotes: 1

Views: 764

Answers (3)

Raxit
Raxit

Reputation: 824

It is good programming style to release it manually. Autorelease will also do the same thing but at it's own time. So it might release it latter also.

Upvotes: 0

Matthew Frederick
Matthew Frederick

Reputation: 22305

Release it after the show. It will retain itself until no longer needed.

Upvotes: 2

Elias
Elias

Reputation: 3360

This is the common way of showing an alert:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Title:" 
                                                message: @"The Message"
                                               delegate: self
                                      cancelButtonTitle: @"OK"
                                      otherButtonTitles: nil];
[alert show];
[alert release];

Upvotes: 2

Related Questions