Je continue d'obtenir une erreur d'accès ex mauvais et je pense que cela a quelque chose à voir avec mon UIPickerView parce que c'est quand l'application se bloque. Tout fonctionne bien jusqu'à ce que je fais un 9ème choix de l'UIPickerView. Chaque fois que l'application se bloque sur le 9e choix. Des idées?UIPickerView EXC Mauvais accès?
- (void)viewDidLoad {
[super viewDidLoad];
list = [[NSMutableArray alloc] init];
[list addObject:@"Anvil"];
[list addObject:@"Apple"];
[list addObject:@"Arrow"];
[list addObject:@"Baby"];
[list addObject:@"Basketball"];
[list addObject:@"Beehive"];
[list addObject:@"Blimp"];
[list addObject:@"Bomb"];
[list addObject:@"Bungee Jumper"];
[list addObject:@"Cactus"];
[list addObject:@"Cake"];
[list addObject:@"Car"];
[list addObject:@"Caterpillar"];
[list addObject:@"Couch"];
[list addObject:@"Dennis"];
anvil = [UIImage imageNamed:@"anvil.png"];
apple = [UIImage imageNamed:@"apple.png"];
arrow = [UIImage imageNamed:@"arrow.png"];
baby = [UIImage imageNamed:@"baby.png"];
basketball = [UIImage imageNamed:@"basketball.png"];
beehive = [UIImage imageNamed:@"beehive.png"];
blimp = [UIImage imageNamed:@"blimp.png"];
bomb = [UIImage imageNamed:@"bomb.png"];
bungeejumper = [UIImage imageNamed:@"bungeejumper.png"];
cactus = [UIImage imageNamed:@"cactus.png"];
cake = [UIImage imageNamed:@"cake.png"];
car = [UIImage imageNamed:@"car.png"];
caterpillar = [UIImage imageNamed:@"caterpillar.png"];
couch = [UIImage imageNamed:@"couch.png"];
dennis = [UIImage imageNamed:@"dennis.png"];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component{
return [list count];
}
-(NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [list objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if([[list objectAtIndex:row] isEqual:@"Anvil"]) {
[object setImage:anvil];
}
else if([[list objectAtIndex:row] isEqual:@"Apple"]) {
[object setImage:apple];
}
else if([[list objectAtIndex:row] isEqual:@"Arrow"]) {
[object setImage:arrow];
}
else if([[list objectAtIndex:row] isEqual:@"Baby"]) {
[object setImage:baby];
}
else if([[list objectAtIndex:row] isEqual:@"Basketball"]) {
[object setImage:basketball];
}
else if([[list objectAtIndex:row] isEqual:@"Beehive"]) {
[object setImage:beehive];
}
else if([[list objectAtIndex:row] isEqual:@"Blimp"]) {
[object setImage:blimp];
}
else if([[list objectAtIndex:row] isEqual:@"Bomb"]) {
[object setImage:bomb];
}
else if([[list objectAtIndex:row] isEqual:@"Bungee Jumper"]) {
[object setImage:bungeejumper];
}
else if([[list objectAtIndex:row] isEqual:@"Cactus"]) {
[object setImage:cactus];
}
else if([[list objectAtIndex:row] isEqual:@"Cake"]) {
[object setImage:cake];
}
else if([[list objectAtIndex:row] isEqual:@"Car"]) {
[object setImage:car];
}
else if([[list objectAtIndex:row] isEqual:@"Caterpillar"]) {
[object setImage:caterpillar];
}
else if([[list objectAtIndex:row] isEqual:@"Couch"]) {
[object setImage:couch];
}
else if([[list objectAtIndex:row] isEqual:@"Dennis"]) {
[object setImage:dennis];
}
}
- (void)dealloc {
[list release];
[super dealloc];
[animation release];
}
Cela ne répond pas à votre question, mais vous voulez vraiment être mettre [super dealloc]; comme la toute dernière ligne de votre méthode dealloc - sinon vous pourriez avoir un plantage lorsque l'objet est libéré! – deanWombourne
Merci, je n'ai pas remarqué ça. – NextRev