문제

I am facing a strange issue in one of my View Controllers, Every thing works fine and loads fine but when ever i set a Value to the View i get an Exception related to layer. However i am not setting any properties to the Layer either in Interface Builder or in the Code. Below is the Log that i receive which right now makes no sense to me

-[__NSCFNumber length]: unrecognized selector sent to instance 0x923a4e0
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x923a4e0'
*** First throw call stack:
(
    0   CoreFoundation                      0x01ef31e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01bf08e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01f90243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x01ee350b ___forwarding___ + 1019
    4   CoreFoundation                      0x01ee30ee _CF_forwarding_prep_0 + 14
    5   UIKit                               0x00a6d463 -[UILabel _shadow] + 45
    6   UIKit                               0x00a6e8c2 -[UILabel drawTextInRect:] + 70
    7   UIKit                               0x00a70dfc -[UILabel drawRect:] + 98
    8   UIKit                               0x0091f453 -[UIView(CALayerDelegate) drawLayer:inContext:] + 504
    9   QuartzCore                          0x00213f39 -[CALayer drawInContext:] + 123
    10  QuartzCore                          0x00213e6a _ZL16backing_callbackP9CGContextPv + 96
    11  QuartzCore                          0x001024fc CABackingStoreUpdate_ + 2656
    12  QuartzCore                          0x00213e02 ___ZN2CA5Layer8display_Ev_block_invoke + 93
    13  QuartzCore                          0x002482d7 x_blame_allocations + 15
    14  QuartzCore                          0x00213c6d _ZN2CA5Layer8display_Ev + 1519
    15  QuartzCore                          0x00213eb9 -[CALayer _display] + 33
    16  QuartzCore                          0x00213676 _ZN2CA5Layer7displayEv + 144
    17  QuartzCore                          0x00213e93 -[CALayer display] + 33
    18  QuartzCore                          0x00210fb7 -[CALayer displayIfNeeded] + 57
    19  QuartzCore                          0x002113b1 -[CALayer renderInContext:] + 192
    20  QuartzCore                          0x00213376 -[CALayer _renderSublayersInContext:] + 413
    21  QuartzCore                          0x002118bc -[CALayer renderInContext:] + 1483
    22  QuartzCore                          0x00213376 -[CALayer _renderSublayersInContext:] + 413
    23  QuartzCore                          0x002118bc -[CALayer renderInContext:] + 1483
    24  QuartzCore                          0x00213376 -[CALayer _renderSublayersInContext:] + 413
    25  QuartzCore                          0x002118bc -[CALayer renderInContext:] + 1483
    26  SilverStar                          0x00011fad -[UIView(ABExtras) imageInNavController:] + 525
    27  SilverStar                          0x00013005 -[CubeNavigationController pushViewController:animated:] + 549
    28  SilverStar                          0x0000c936 -[MSArticleViewController detailsbuttonTapped:] + 438
    29  libobjc.A.dylib                     0x01c02880 -[NSObject performSelector:withObject:withObject:] + 77
    30  UIKit                               0x008b23b9 -[UIApplication sendAction:to:from:forEvent:] + 108
    31  UIKit                               0x008b2345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    32  UIKit                               0x009b3bd1 -[UIControl sendAction:to:forEvent:] + 66
    33  UIKit                               0x009b3fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
    34  UIKit                               0x009b3243 -[UIControl touchesEnded:withEvent:] + 641
    35  UIKit                               0x00c482e3 _UIGestureRecognizerUpdate + 7166
    36  UIKit                               0x008f1a5a -[UIWindow _sendGesturesForEvent:] + 1291
    37  UIKit                               0x008f2971 -[UIWindow sendEvent:] + 1021
    38  UIKit                               0x008c45f2 -[UIApplication sendEvent:] + 242
    39  UIKit                               0x008ae353 _UIApplicationHandleEventQueue + 11455
    40  CoreFoundation                      0x01e7c77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    41  CoreFoundation                      0x01e7c10b __CFRunLoopDoSources0 + 235
    42  CoreFoundation                      0x01e991ae __CFRunLoopRun + 910
    43  CoreFoundation                      0x01e989d3 CFRunLoopRunSpecific + 467
    44  CoreFoundation                      0x01e987eb CFRunLoopRunInMode + 123
    45  GraphicsServices                    0x036c25ee GSEventRunModal + 192
    46  GraphicsServices                    0x036c242b GSEventRun + 104
    47  UIKit                               0x008b0f9b UIApplicationMain + 1225

Note: I am not sure which Code Section you might require. So, Let me know i will add in the Question here

도움이 되었습니까?

해결책

You are passing NSNumber instead of NSString. Try this:

NSString *myString = [aNumber stringValue]; // aNumber is a NSNumber
self.label.text = myString

Hope this helps.. :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top