Я работаю над проектом в xCode для iPhone, где я получаю ошибку EXC_BAD_ACCESS, ОДНАКО, я получаю ошибку только при переходе через функцию, которую пытаюсь отладить. Когда я снимаю точку останова с функции, но все же запускаю проект в режиме отладки, я никогда не получаю эту ошибку. Есть ли в любом случае, чтобы решить эту проблему или выяснить, что вызывает ошибку EXC_BAD_ACCESS.
Ошибка появляется в строке: for ( BEUCharacterAIBehavior *behavior in behavior_.behaviors )
Однако при пошаговом выполнении значение поведения_.behaviors выделяется и сохраняется. NSZombiesEnabled установлен, но все еще получает загадочное сообщение об ошибке.
Код:
-(BEUCharacterAIBehavior *)getHighestValueBehaviorFromBehavior:(BEUCharacterAIBehavior *)behavior_ {
//if the behavior is a leaf then stop checking because there are no sub behaviors
if([behavior_ isLeaf]) return behavior_;
//temp variable for highest value behavior so far
BEUCharacterAIBehavior *highest = nil;
//NSLog(@"BEHAVIORS:%@",behavior_.behaviors);
for ( BEUCharacterAIBehavior *behavior in behavior_.behaviors )
{
//if there is a highest value behavior check if the highest value behavior has a larger value than the new one
if(highest)
{
if(highest.lastValue > behavior.value) continue;
}
//if there is no current behavior then the highest is now the behavior were checking because we have nothing to check against
if(!currentBehavior) highest = behavior;
//Make sure the current behavior is not the same behavior as the new one
else if(currentBehavior != behavior)
{
//can the new behaviors parent run multiple times in a row
if(!behavior.parent.canRunMultipleTimesInARow)
{
//make sure the current and new behaviors parents arent the same if they are continue to next behavior
if(currentBehavior.parent != behavior.parent)
{
continue;
}
}
highest = behavior;
//If current behavior and new behavior are the same make sure they can run multiple times
} else if(currentBehavior.canRunMultipleTimesInARow)
{
highest = currentBehavior;
}
}
//NSLog(@"GOING TO GET HIGHEST VALUE BEHAVIOR FROM BEHAVIOR: %d",highest.retainCount);
if(!highest) return nil;
return [self getHighestValueBehaviorFromBehavior:highest];//highest;
}
стек ошибок
0 0x02aebdcb в object_getClass
1 0x00002ac0 в
2 0x00014bb9 in - [BEUCharacterAI getHighestValueBehaviorFromBehavior:] в BEUCharacterAI.m: 115
3 0x00014b6b in - [BEUCharacterAI getHighestValueBehavior] в BEUCharacterAI.m: 103
4 0x00014904 in - [BEUCharacterAI update:] на BEUCharacterAI.m: 68
5 0x00008975 in - [BEUCharacter step:] at BEUCharacter.m: 229
6 0x00022aeb in - [шаг эскимосского персонажа:] в EskimoCharacter.m: 28
7 0x0000ed2b in - [шаг BEUObjectController:] на BEUObjectController.m: 381
8 0x00003651 in - [шаг BEUGame:] на BEUGame.m: 63
9 0x0007cc42 in - [CCTimer fire:] at CCScheduler.m: 87
10 0x0007d846 in - [тик CCScheduler:] на CCScheduler.m: 212
11 0x000500b3 in - [mainCoop CCDirector] на CCDirector.m: 208
12 0x000532b3 in - [CCDisplayLinkDirector preMainLoop:] на CCDirector.m: 1055
13 0x00796f06 в CA :: Display :: DisplayLink :: dispatch
14 0x0079704b в CA :: Display :: EmulatorDisplayLink :: callback
15 0x029810f3 в CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
16 0x02982734 в __CFRunLoopDoTimer
17 0x028df689 в __CFRunLoopRun
18 0x028dec00 в CFRunLoopRunSpecific
19 0x028deb21 в CFRunLoopRunInMode
20 0x03e96378 в GSEventRunModal
21 0x03e9643d в GSEventRun
22 0x0083bf89 в UIApplicationMain
23 0x00002b50 в основном на main.m: 13