IPhone - Memory Management problems.

Posted by user321721 on Stack Overflow See other posts from Stack Overflow or by user321721
Published on 2010-04-20T21:26:41Z Indexed on 2010/04/20 21:33 UTC
Read the original article Hit count: 224

Filed under:
|

i am going over my code and trying to get a handle on proper memory management. This code:

imageView = [[[UIImageView alloc] initWithImage:myImage] autorelease];

causes my application to crash. I am using multiple view controllers within a nav bar controller. The app works fine, i cant select a person from the first view controller (tableview) and it puts me to a list of that persons photos, i can then select a photo from that view controller (tableview) and move to a final view with a scrollview for viewing the photo. Once i hit back on the navbar the previous view loads (list of photos in a tableview) however the app crashes right before the row is deselected using this code:

  • (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];
    if(RowSelected != nil) { [MainTableView deselectRowAtIndexPath:RowSelected animated:YES]; } }

Row selected is stored when a the user clicks a row.

If i leave the code as :
imageView = [[UIImageView alloc] initWithImage:myImage];

The app runs fine. Am i doing something wrong? do i not need to autorelease this?

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-management