ios - SIGABRT错误-分段控制

标签 ios objective-c sigabrt

我有一个分段控件,根据所选内容,它旨在为 NS 字符串分配一个值,如下所示:

-(IBAction)driverKnownIndexChanged{
    switch (self.driverKnown.selectedSegmentIndex) {
        case 0:
            driverKnownResponse = @"Yes";
            break;

        case 1:
            driverKnownResponse = @"No";
            break;
        default:
            break;
    }
}

但是,它在以下行抛出 SIGABRT:

#import "RoadSafetyAppAppDelegate.h"

int main(int argc, char * argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([RoadSafetyAppAppDelegate class]));
    }
}

这是控制台输出:

2014-01-30 13:32:16.403 Road Safety App V2[3873:70b] -[DobInAHoonViewController driverKnown:]: unrecognized selector sent to instance 0xcd23440
2014-01-30 13:32:16.409 Road Safety App V2[3873:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DobInAHoonViewController driverKnown:]: unrecognized selector sent to instance 0xcd23440'
*** First throw call stack:
(
    0   CoreFoundation                      0x01d8f7e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01b0f8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x01e2c843 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x01d7fb0b ___forwarding___ + 1019
    4   CoreFoundation                      0x01d7f6ee _CF_forwarding_prep_0 + 14
    5   libobjc.A.dylib                     0x01b2182b -[NSObject performSelector:withObject:] + 70
    6   UIKit                               0x007d8309 -[UIApplication sendAction:to:from:forEvent:] + 108
    7   UIKit                               0x007d8295 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    8   UIKit                               0x008d90a1 -[UIControl sendAction:to:forEvent:] + 66
    9   UIKit                               0x008d9496 -[UIControl _sendActionsForEvents:withEvent:] + 577
    10  UIKit                               0x008d90d6 -[UIControl sendActionsForControlEvents:] + 48
    11  UIKit                               0x00947572 -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 598
    12  UIKit                               0x009498c3 -[UISegmentedControl touchesEnded:withEvent:] + 175
    13  UIKit                               0x00b6ccc3 _UIGestureRecognizerUpdate + 7166
    14  UIKit                               0x008177ca -[UIWindow _sendGesturesForEvent:] + 1291
    15  UIKit                               0x008186e1 -[UIWindow sendEvent:] + 1021
    16  UIKit                               0x007ea542 -[UIApplication sendEvent:] + 242
    17  UIKit                               0x007d42f3 _UIApplicationHandleEventQueue + 11455
    18  CoreFoundation                      0x01d18d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    19  CoreFoundation                      0x01d1870b __CFRunLoopDoSources0 + 235
    20  CoreFoundation                      0x01d357ae __CFRunLoopRun + 910
    21  CoreFoundation                      0x01d34fd3 CFRunLoopRunSpecific + 467
    22  CoreFoundation                      0x01d34deb CFRunLoopRunInMode + 123
    23  GraphicsServices                    0x0344f4ed GSEventRunModal + 192
    24  GraphicsServices                    0x0344f32a GSEventRun + 104
    25  UIKit                               0x007d6eeb UIApplicationMain + 1225
    26  Road Safety App V2                  0x00002f9d main + 141
    27  libdyld.dylib                       0x0308470d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)  

以及关于为什么我遇到这个问题的想法?并且也将不胜感激。

最佳答案

此行 switch (self.driverKnown.selectedSegmentIndex) { 正在访问名为 driverKnown 的属性,但该驱动程序未知。堆栈跟踪和异常告诉您 driverKnown 是该属性的未声明或 unknock getter 方法。

异常调用 DobInAHoonViewController ,在该行代码中它将是 self。 driverKnown 是否应该是您的 UISegmentedControl 的名称?我们可以看到所说的 UISegmentedControl 的创建吗?

关于ios - SIGABRT错误-分段控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21446778/

相关文章:

objective-c - 当返回值是类型转换的父类时,对方法的返回值进行类型转换?

objective-c - Objective-C : Adaptive Toolbar On Orientation Change

ios - 此类不符合关键问题的关键值编码

xamarin - 执行 native 代码时出现 SIGABRT xamarin.ios

c - C Linux 中的 SIGABRT

ios - 为什么我的 Vapor 查询总是失败?

android - IOS Swift 中的应用类

ios - 使用相机和相册

ios - 当我点击 TextField 并且不显示键盘时。我该如何使用?

iphone - 在 iOS 上动画动态整数值?