iPhone SDK: Memory leak on picker
Posted
by bbftsoftware
on Stack Overflow
See other posts from Stack Overflow
or by bbftsoftware
Published on 2010-03-29T14:57:30Z
Indexed on
2010/03/29
15:23 UTC
Read the original article
Hit count: 569
iphone-sdk
I have created a picker for my users to pick from a list of countries. The problem is that repeated opening and closing of the picker is resulting in “EXC_BAD_ACCESS” error. I suspect it might be a memory leak but I am not sure. I was hoping someone could shed some insight into why this might be happening?
//data source for UIPicker
NSArray *arrayCountryChoices;
arrayCountryChoices = [[NSArray alloc] initWithObjects:@"TK=TOKELAU",
@"TJ=TAJIKISTAN",
@"TH=THAILAND",
@"TG=TOGO",
@"TF=FRENCH SOUTHERN TERRITORIES",
@"GY=GUYANA",
@"TD=CHAD", nil];
//opening the picker
CountryViewController *countryVC = [[CountryViewController alloc] initWithNibName:@"CountryView" bundle:nil];
countryVC.delegate = self;
[self presentModalViewController:countryVC animated:YES];
[countryVC release];
//here is where I grab the data
//close country selector
[self dismissModalViewControllerAnimated:YES];
//parse out code
NSString *strCode = [chosenCountry substringToIndex:2];
//set the gui
txtCountry.text = strCode;
I think it may be because I am trying to release the Country Selector before the delegate has a chance to get its data? Also I am wondring if I should not release the picker until the screen that calls it is released.
Thanks in advance.
© Stack Overflow or respective owner