嗨,我在代码中遇到了 EXC_BAD_ACCESS,
我正在尝试在类 PurchaseTowerMenuLayer 中运行一个方法,方法来自 UnitDatabase 类:
PurchaseTowerMenuLayer.m:
delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// getUnitDatabase returns UnitDatabase class from GameScene class
[[[delegate getGameScene] getUnitDatabase] createUnit:@"t01"]; //EXC_BAD_ACCESS happens here
单位数据库.m:
-(void)createUnit:(NSString *)unitID
{
typeString = [unitID substringWithRange:NSMakeRange(0,1)];
numberString = [unitID substringWithRange:NSMakeRange(1,2)];
Unit *unit;
if(unitID == @"t00")
[unit setUnitID:unitID];
etc...
}
我在做什么来得到这个错误?它应该是什么样子?
提前致谢!