简体   繁体   中英

terminating uncaught exception of type NSException

My game is constantly crashing after pressing a certain button after restarting the game.

An animation is always running during the game in the ViewController I'm running the game on.

Here is the crash log. Is there any way to detect how is this crash related to my animation?

2014-08-05 00:21:30.044 windmill[702:90b] -[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10
2014-08-05 00:21:30.053 windmill[702:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer doubleValue]: unrecognized selector sent to instance 0xec32a10'
*** First throw call stack:
(
    0   CoreFoundation                      0x01c501e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x019cf8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01ced243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x01c4050b ___forwarding___ + 1019
    4   CoreFoundation                      0x01c400ee _CF_forwarding_prep_0 + 14
    5   QuartzCore                          0x0013b9b8 CAObject_setValueForKeyPath_ + 2435
    6   QuartzCore                          0x0012129b -[CALayer setValue:forKeyPath:] + 471
    7   QuartzCore                          0x00105d51 -[CABasicAnimation applyForTime:presentationObject:modelObject:] + 1178
    8   QuartzCore                          0x0012415c _ZN2CA5Layer18presentation_layerEPNS_11TransactionE + 494
    9   QuartzCore                          0x00127cbe -[CALayer presentationLayer] + 43
    10  UIKit                               0x006eb0f1 _UIViewEatsTouches + 142
    11  UIKit                               0x006eb250 -[UIView(Geometry) hitTest:withEvent:] + 114
    12  UIKit                               0x006eb4f4 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke + 132
    13  CoreFoundation                      0x01cccd86 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
    14  CoreFoundation                      0x01cccc5f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
    15  UIKit                               0x006eb35c -[UIView(Geometry) hitTest:withEvent:] + 382
    16  UIKit                               0x006eb4f4 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke + 132
    17  CoreFoundation                      0x01cccd86 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 102
    18  CoreFoundation                      0x01cccc5f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
    19  UIKit                               0x006eb35c -[UIView(Geometry) hitTest:withEvent:] + 382
    20  UIKit                               0x006daeb1 __54+[UIWindow _hitTestToPoint:pathIndex:forEvent:screen:]_block_invoke + 175
    21  UIKit                               0x006dad1e +[UIWindow _topVisibleWindowPassingTest:] + 198
    22  UIKit                               0x006dadfa +[UIWindow _hitTestToPoint:pathIndex:forEvent:screen:] + 176
    23  UIKit                               0x0068c5bb _UIApplicationHandleEventQueue + 7975
    24  CoreFoundation                      0x01bd977f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    25  CoreFoundation                      0x01bd910b __CFRunLoopDoSources0 + 235
    26  CoreFoundation                      0x01bf61ae __CFRunLoopRun + 910
    27  CoreFoundation                      0x01bf59d3 CFRunLoopRunSpecific + 467
    28  CoreFoundation                      0x01bf57eb CFRunLoopRunInMode + 123
    29  GraphicsServices                    0x0341c5ee GSEventRunModal + 192
    30  GraphicsServices                    0x0341c42b GSEventRun + 104
    31  UIKit                               0x0068ff9b UIApplicationMain + 1225
    32  windmill                            0x00004afd main + 141
    33  libdyld.dylib                       0x03103725 start + 0
    34  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

When I press buttons in the view , the app crashes. Here is the animation code:

    CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];

    fullRotation.fromValue = [NSNumber numberWithFloat:0];
    fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
    fullRotation.duration = 4;
    fullRotation.repeatCount= 1000;
    [[stick layer] addAnimation:fullRotation forKey:@"60"];}

I'm sorry if the code is messed up , I'm still learning and building small apps and games to get a better practice. Thanks.

您应该删除具有fullRotation.fromValue的行,因为它不应该为其分配CALayer。

fullRotation.fromValue = self.view.layer.presentationLayer;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM