オブジェクトに触れると動くアプリを作っています。移動後、割り当てが解除されます。30 回以上の移動の後、EXC_BAD_ACESS という名前で CODE = 1 の例外がスローされます。例外がスローされるのはなぜですか?
if (myselunit!=nil) {
touch = [touches anyObject];
location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location]; // Locks on to touch's coordinates
realx = location.x;
realy = location.y;
realDest = ccp(location.x, location.y);
int offRealX = realx - myselunit.position.x; // exception occurs here
int offRealY = realy - myselunit.position.y;
float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY));
float velocity = 50*myselunit.speed; // 480pixels/1sec
float realMoveDuration = length/velocity;
[myselunit runAction:[CCSequence actions:[CCMoveTo actionWithDuration:realMoveDuration position:realDest],[CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)],nil]];
// [myselunit runAction:[CCSequence actions:[CCCallFuncN actionWithTarget:self selector:@selector(staminaUse:)],nil]];
NSLog(@"%f",location.x);
myselunit = nil;
}
これは、myselunt の逆流エラー リストです。
逆流:
スレッド 1
0x1fa509f: movl (%edi), %esi
if (myselunit!=nil && myselunit.unitType != 0) {
0x19f9e99: addl $28, %esp
[handler.delegate performSelector:helper.touchesSel withObject:mutableTouches withObject:event]; [CCTouchDispatcher touches:withEvent:withTouchType:] 1 [self touches:touches withEvent:event withTouchType:kCCTouchBegan]; 4 -[CCTouchDispatcher touchesBegan:withEvent:] 1 [touchDelegate_ touchesBegan:touches withEvent:event]; 5 - [EAGLView touchesBegan:withEvent:] 1 0x8562cf: movl 6769896(%esi), %eax 6 - [UIWindow_sendTouchesForEvent:] 1 0x82e626: xorl %eax, %eax 18 UIApplicationMain 1 int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); 19 メイン // (メモリ エラー) 1 0x2815: movl %eax, (%esp) 20 開始 0スレッド 3 0x9062690a: jae 0x9062691a ; kevent + 26 0 kevent 1 libdispatch.dylib`_dispatch_mgr_thread: 2_dispatch_mgr_thread 1
- スレッド 6 0x9062583e: jae 0x9062584e ; __psynch_cvwait + 26 0_psynch_cvwait 1 0x97a76ed9: movl %ebx, %ecx 4_pthread_start 1