Objective-C NSInvalidArgumentException

时间:2011-02-25 06:35:44

标签: iphone objective-c iphone-sdk-3.0 ios4

我有一个有三个选择的分段控制,每个选项都进行不同的计算。计算正在操纵字符串。

我注意到当我第一次启动应用程序时,字符串是nil,顺便说一句。如果我触摸分段控件上的所有三个选项,应用程序将崩溃,这是堆栈跟踪。

我到处搜索但仍无法找到问题。

[Session started at 2011-02-25 01:21:03 -0500.]
2011-02-25 01:21:07.075 tipApp[2184:207] -[_UIStretchableImage isEqualToString:]: unrecognized selector sent to instance 0x4b5c0a0
2011-02-25 01:21:07.078 tipApp[2184:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIStretchableImage isEqualToString:]: unrecognized selector sent to instance 0x4b5c0a0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00db7be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f0c5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x00db96fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00d29366 ___forwarding___ + 966
    4   CoreFoundation                      0x00d28f22 _CF_forwarding_prep_0 + 50
    5   tipApp                              0x00006f13 -[tipAppViewController exact] + 56
    6   tipApp                              0x00006ed3 -[tipAppViewController mirror] + 4772
    7   tipApp                              0x000057f2 -[tipAppViewController segmentedControlIndexChanged] + 104
    8   UIKit                               0x002c0a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    9   UIKit                               0x0034f1b5 -[UIControl sendAction:to:forEvent:] + 67
    10  UIKit                               0x00351647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    11  UIKit                               0x0034f16c -[UIControl sendActionsForControlEvents:] + 49
    12  UIKit                               0x0038e6b2 -[UISegmentedControl setSelectedSegmentIndex:] + 574
    13  UIKit                               0x0039317e -[UISegmentedControl touchesBegan:withEvent:] + 971
    14  UIKit                               0x002e5025 -[UIWindow _sendTouchesForEvent:] + 395
    15  UIKit                               0x002c637a -[UIApplication sendEvent:] + 447
    16  UIKit                               0x002cb732 _UIApplicationHandleEvent + 7576
    17  GraphicsServices                    0x016eda36 PurpleEventCallback + 1550
    18  CoreFoundation                      0x00d99064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    19  CoreFoundation                      0x00cf96f7 __CFRunLoopDoSource1 + 215
    20  CoreFoundation                      0x00cf6983 __CFRunLoopRun + 979
    21  CoreFoundation                      0x00cf6240 CFRunLoopRunSpecific + 208
    22  CoreFoundation                      0x00cf6161 CFRunLoopRunInMode + 97
    23  GraphicsServices                    0x016ec268 GSEventRunModal + 217
    24  GraphicsServices                    0x016ec32d GSEventRun + 115
    25  UIKit                               0x002cf42e UIApplicationMain + 1160
    26  tipApp                              0x00002888 main + 102
    27  tipApp                              0x00002819 start + 53
)
terminate called after throwing an instance of 'NSException'

[Session started at 2011-02-25 01:26:59 -0500.]

2 个答案:

答案 0 :(得分:3)

-[tipAppViewController exact]方法中,您将isEqualToString:选择器发送给无法处理它的对象。

如果这没有帮助,可以发布exact方法的代码。

答案 1 :(得分:0)

您可以发布分段控件的代码吗?您是否尝试浏览UIScrollview上的子视图?这可能会导致抛出异常。退房:

http://wiresareobsolete.com/wordpress/2010/03/uiscrollview-has-a-secret/