В моем коде я создаю 5 наборов объектов и 5 NSArrays, содержащих эти объекты. В конце моего метода два массива освобождаются должным образом, но три других вызывают сбой моего приложения.
Создание
UIImageView *image0 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TankAxe.png"]];
NSArray *imageArray = [[NSArray alloc] initWithObjects:image0, nil];
NSString *name0 = [NSString stringWithString:@"Pistol"];
NSArray *nameArray = [[NSArray alloc] initWithObjects:name0, nil];
NSNumber *price0 = [NSNumber numberWithInt:100];
NSArray *priceArray = [[NSArray alloc] initWithObjects:price0, nil];
NSNumber *round0 = [NSNumber numberWithInt:0];
NSArray *roundArray = [[NSArray alloc] initWithObjects:round0, nil];
NSNumber *priceRound0 = [NSNumber numberWithInt:0];
NSArray *priceRoundArray = [[NSArray alloc] initWithObjects:priceRound0, nil];
Высвобождение
[name0 release];
[nameArray release]; //Releases properly
[image0 release];
[imageArray release]; //Releases properly
[price0 release];
NSLog(@"%i",[priceArray retainCount]); //Returns 1
[priceArray release]; //Source of the crash
[round0 release];
[roundArray release]; //Also crashes
[priceRound0 release];
[priceRoundArray release]; //Also Crashes
Кто-нибудь знает, как правильно освобождать массивы, содержащие NSNumbers?