Tôi đang làm việc trên một dự án trong xCode cho iPhone, nơi tôi nhận được lỗi EXC_BAD_ACCESS, BAO GIỜ, tôi chỉ nhận được lỗi khi bước qua một hàm tôi đang cố gỡ lỗi. Khi tôi mất breakpoint của tôi ra khỏi chức năng, nhưng vẫn chạy dự án trong Debug Mode, tôi không bao giờ nhận được lỗi này. Có anyway để giải quyết điều này hoặc tìm hiểu những gì đang gây ra lỗi EXC_BAD_ACCESS.xCode cho lỗi EXC_BAD_ACCESS của iPhone chỉ xảy ra khi bước qua trình gỡ rối?
Các lỗi đến trên dòng: for (BEUCharacterAIBehavior *behavior in behavior_.behaviors)
Tuy nhiên khi bước qua behavior_.behaviors giá trị được phân bổ và giữ lại. NSZombiesEnabled được đặt nhưng vẫn nhận được thông báo lỗi khó hiểu.
Code:
-(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;
}
Lỗi chồng
0 0x02aebdcb trong object_getClass
1 0x00002ac0 trong
2 0x00014bb9 trong - [BEUCharacterAI getHighestValueBehaviorFromBehavior:] lúc BEUCharacterAI.m: 115
3 0x00014b6b trong - [BEUCharacterAI getHighestValueBehavior] tại BEUCharacterAI.m: 103
4 0x00014904 trong - [BEUCharacterAI cập nhật:] lúc BEUCharacterAI.m: 68
5 0x00008975 trong - [BEUCharacter bước:] lúc BEUCharacter.m: 229
6 0x00022aeb trong - [EskimoCharacter bước:] lúc EskimoCharacter.m: 28
7 0x0000ed2b trong - [BEUObjectController bước:] lúc BEUObjectController.m: 381
8 0x00003651 trong - [BEUGame bước:] lúc BEUGame.m: 63
9 0x0007cc42 trong - [CCTimer lửa:] lúc CCScheduler.m : 87
10 0x0007d846 trong - [CCScheduler đánh dấu:] lúc CCScheduler.m: 212
11 0x000500b3 trong - [CCDirector mainloop] tại CCDirector.m: 208
12 0x000532b3 trong - [CC DisplayLinkDirector preMainLoop:] lúc CCDirector.m: 1055
13 0x00796f06 ở CA :: Display :: DisplayLink :: văn
14 0x0079704b trong CA :: Display :: EmulatorDisplayLink :: callback
15 0x029810f3 trong CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
16 0x02982734 trong __CFRunLoopDoTimer
17 0x028df689 trong __CFRunLoopRun
18 0x028dec00 trong CFRunLoopRunSpecific
19 0x028deb21 trong CFRunLoopRunInMode
20 0x03e96378 trong GSEventRunModal
21 0x03e9643d trong GSEven trun
22 0x0083bf89 trong UIApplicationMain
23 0x00002b50 ở chính tại main.m: 13
Tôi không có thiết bị để kiểm tra khi tôi gặp phải lỗi này, nhưng khi tôi đã sửa lỗi và bước qua thiết bị của mình, không có lỗi nào xảy ra. Vì vậy, điều này dường như chỉ là giả lập. –