我有以下课程:
#import "SharedData.h"
static int selectedCountryIndex;
static NSMutableArray *imageDataObjectsArray;
@implementation SharedData
+(void)insertIntoImageDataObjectsArray:(ImageData *)imageData:(int)index{
if (!imageDataObjectsArray)
**imageDataObjectsArray = [[NSMutableArray alloc]init ];**
[imageDataObjectsArray insertObject:imageData atIndex:index];
}
+(ImageData *)getFromImageDataObjectsArray:(int)index{
return [imageDataObjectsArray objectAtIndex:index];
}
+(void)setSelectedCountryIndex:(int)selectedCountryIndexArg{
selectedCountryIndex = selectedCountryIndexArg;
}
+(int)getSelectedCountryIndex{
return selectedCountryIndex;
}
@end
此类仅用于接受来自一个视图的数据,然后允许另一个视图获取该数据。但是,无论何时调用 insertIntoImageDataObjectsArray 方法,标有星号的行都会导致“EXC_BAD_ACCESS”崩溃。这是对该方法的调用:
[SharedData insertIntoImageDataObjectsArray:imageDataObject :[result doubleValue]-1];
有人知道为什么吗?