更改场景时,我很难解决崩溃问题。这是被替换场景的dealloc方法。它正在被调用,我知道没有内存泄漏或堆膨胀。谁能建议我可能会犯什么愚蠢/明显的错误。我为白痴道歉。
-(void) dealloc
{
NSLog(@"Dungeon.m dealloc called");
[self removeAllChildrenWithCleanup:true];
[self unscheduleAllSelectors];
[[CCScheduler sharedScheduler]unscheduleAllSelectors];
if (entityList) [entityList release];
if (lopsidedList) [lopsidedList release];
if (monsterNames) [monsterNames release];
if (menuSprites) [menuSprites release];
if (menuLabels) [menuLabels release];
if (monsterLevels) [monsterLevels release];
if (theMagicFactory) [theMagicFactory release];
if (theDM) [theDM release];
if (theDisplay) [theDisplay release];
if (aDungeonLevel) [aDungeonLevel release];
NSLog([NSString stringWithFormat:@"Player Retain Count: %i",[thePlayer retainCount]]);
[super dealloc]
}
我已经确认重要列出的对象的 deallocs 被称为:
2012-09-09 10:51:31.840 Pocket Dungeons[947:707] Dungeon.m dealloc called
2012-09-09 10:51:31.878 Pocket Dungeons[947:707] DungeonMaster.m dealloc called.
2012-09-09 10:51:31.910 Pocket Dungeons[947:707] DungeonDisplay.m dealloc called
2012-09-09 10:51:31.915 Pocket Dungeons[947:707] dungeonlevel.m dealloccalled
这是不断变化的场景代码:
else if (whatIsHere==STAIRS_UP) {
if (thePlayer.currentDungeonLevel==1) {
NSLog([NSString stringWithFormat:@"Self Retain Count: %i",[self retainCount]]);
thePlayer.theDungeon = nil;
theDM.theDungeon = nil;
theDisplay.theDungeon = nil;
for (int i=0; i<[aDungeonLevel.mArray count]; i++) {
Monster *aMonster = [aDungeonLevel.mArray objectAtIndex:i];
aMonster.theDungeon = nil;
}
NSLog([NSString stringWithFormat:@"Self Retain Count: %i",[self retainCount]]);
// CCScene *aScene = [Town nodeWithPlayer:thePlayer];
CCScene *aScene = [CharacterMaker2 nodeWithPlayer:thePlayer];
[[CCDirector sharedDirector] replaceScene:aScene];
这是发生崩溃的地方:
0 0x34311f78 in objc_msgSend ()
1 0x000fef28 in -[CCDirector setNextScene] at /Users/nehrujuman212/Documents/Pocket Dungeons/Pocket Dungeons/libs/cocos2d/CCDirector.m:429
2 0x0014ab44 in -[CCDirectorIOS drawScene] at /Users/nehrujuman212/Documents/Pocket Dungeons/Pocket Dungeons/libs/cocos2d/Platforms/iOS/CCDirectorIOS.m:160
3 0x0014c858 in -[CCDirectorDisplayLink mainLoop:] at /Users/nehrujuman212/Documents/Pocket Dungeons/Pocket Dungeons/libs/cocos2d/Platforms/iOS/CCDirectorIOS.m:721
4 0x33fd386e in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) ()
5 0x33fd37c4 in CA::Display::IOMFBDisplayLink::callback(__IOMobileFramebuffer*, unsigned long long, unsigned long long, unsigned long long, void*) ()
6 0x37387000 in IOMobileFramebufferVsyncNotifyFunc ()
7 0x31bf060c in IODispatchCalloutFromCFMessage ()
8 0x3228af12 in __CFMachPortPerform ()
9 0x32295522 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
10 0x322954c4 in __CFRunLoopDoSource1 ()
11 0x32294312 in __CFRunLoopRun ()
12 0x322174a4 in CFRunLoopRunSpecific ()
13 0x3221736c in CFRunLoopRunInMode ()
14 0x3136e438 in GSEventRunModal ()
15 0x31d16cd4 in UIApplicationMain ()
16 0x0016ea1e in main at /Users/nehrujuman212/Documents/Pocket Dungeons/Pocket Dungeons/main.m:14
谢谢。