IPhone - Memory Management problems.
- by user321721
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!