스택 추적에서 NSCFNumber 및 UILabel drawTextInRect와 함께 인식 할 수없는 선택기 오류가 발생합니다. 스택 트레이스는 다음과 같습니다.SIGABRT NSCFNumber 길이
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0xad5a260'
*** First throw call stack:
(
0 CoreFoundation 0x01f039e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01c838e5 objc_exception_throw + 44
2 CoreFoundation 0x01fa0a43 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01ef3d0b ___forwarding___ + 1019
4 CoreFoundation 0x01ef38ee _CF_forwarding_prep_0 + 14
5 UIKit 0x00b02773 -[UILabel _shadow] + 45
6 UIKit 0x00b03bd2 -[UILabel drawTextInRect:] + 70
7 UIKit 0x00b0610c -[UILabel drawRect:] + 98
8 UIKit 0x009b4893 -[UIView(CALayerDelegate) drawLayer:inContext:] + 504
9 QuartzCore 0x0060db39 -[CALayer drawInContext:] + 123
10 QuartzCore 0x0060da6a _ZL16backing_callbackP9CGContextPv + 96
11 QuartzCore 0x004fbf3c CABackingStoreUpdate_ + 2656
12 QuartzCore 0x0060da02 ___ZN2CA5Layer8display_Ev_block_invoke + 93
13 QuartzCore 0x00641ee3 x_blame_allocations + 15
14 QuartzCore 0x0060d86d _ZN2CA5Layer8display_Ev + 1519
15 QuartzCore 0x0060dab9 -[CALayer _display] + 33
16 QuartzCore 0x0060d276 _ZN2CA5Layer7displayEv + 144
17 QuartzCore 0x0060da93 -[CALayer display] + 33
18 QuartzCore 0x00601c43 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 323
19 QuartzCore 0x00601cbc _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 38
20 QuartzCore 0x005683ee _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
21 QuartzCore 0x00569779 _ZN2CA11Transaction6commitEv + 393
22 QuartzCore 0x00569e4c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
23 CoreFoundation 0x01ecbb6e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
24 CoreFoundation 0x01ecbabf __CFRunLoopDoObservers + 399
25 CoreFoundation 0x01ea9a54 __CFRunLoopRun + 1076
26 CoreFoundation 0x01ea91d3 CFRunLoopRunSpecific + 467
27 CoreFoundation 0x01ea8feb CFRunLoopRunInMode + 123
28 GraphicsServices 0x03d1c5ee GSEventRunModal + 192
29 GraphicsServices 0x03d1c42b GSEventRun + 104
30 UIKit 0x009463db UIApplicationMain + 1225
31 PocketCTF 0x00026e8d main + 141
32 libdyld.dylib 0x02881725 start + 0
)
Xcode가 기본 실행 루프에 중단 점을 지정했기 때문에 어떤 행이이 오류의 원인인지는 잘 모르겠습니다. 예외 및 기호 중단 점을 사용하여 어떤 줄이 문제를 일으키는 지 알 수 있지만 사용하지 않으려 고 시도했습니다. 이 문제의 원인이 무엇인지 알기 위해 할 수있는 일이 있습니까? 내가 여기에 게시 한 후
NSNumber가 '길이'메소드를 구현하지 않았기 때문입니다. 유형이 NSString이 될 것으로 기대하는 NSNumber 값을 설정할 수도 있습니다. – danielbeard
NSString을 예상하는 API (UILabel setText)에 NSNumber 객체를 전달했습니다. –
("Unrecognized selector"는 네임드 클래스에 네임드 메소드 호출을 요청했음을 의미하며, 그 클래스에 그 이름으로 메소드가 없다는 것을 의미합니다. 예외 추적을 조사하면 UILabel에서 빠져 나오고,'setText'는 NSNumber 매개 변수로 불리는 유일한 단점은 가짜 값을 설정 한 후 얼마되지 않아 UILabel이 렌더링되지 않았기 때문에 어떤'setText1' 호출이 범인인지 알아내는 것입니다. –