内存问题有如下代码:
有 EXC_BAS_ACCESS
@interface MapList : NSObject
{
NSArray* m_units;
}
-(MapList*) loadMapListWithLevel:(uchar) lvl chapter: (uchar) chapt;
-(void) dealloc;
@end
和实施:
-(MapList*) loadMapListWithLevel:(uchar) lvl chapter: (uchar) chapt
{
self =[super init];
if (self)
{
{
...
NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity:size];
for (uint j=0;j<size;j++)
{
obj =[[SpriteDB alloc] init];
[array addObject:obj];
[obj release];
}
if (i==0)
m_units = [NSArray arrayWithArray:array];
[array release];
}
...
}
return self;
}
-(void) dealloc
{
[m_units release];
[super dealloc];
}
在一种方法中,我这样称呼它们
MapList* mpl = [[MapList alloc] loadMapListWithLevel:level chapter:chapter];
[mpl release];
问题出在哪里?当我评论[m_units release];
它的工作...