Ios libc++abi.dylib:以NSException(lldb)类型的未捕获异常终止

Ios libc++abi.dylib:以NSException(lldb)类型的未捕获异常终止,ios,xcode,swift,Ios,Xcode,Swift,所以我回去重新编写代码,确保参数都在正确的位置。但是现在,当我在iOS模拟器中运行我的应用程序时,我在调试区域中得到一个线程1:SIGABRT错误和以下错误: 2014-11-04 00:39:12.288 Juxta[60526:1144351] +[_TtCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7Counter parseClassName]: unrecognized selector sent to class 0x1059bb6

所以我回去重新编写代码,确保参数都在正确的位置。但是现在,当我在iOS模拟器中运行我的应用程序时,我在调试区域中得到一个线程1:SIGABRT错误和以下错误:

2014-11-04 00:39:12.288 Juxta[60526:1144351] +[_TtCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7Counter parseClassName]: unrecognized selector sent to class 0x1059bb640
2014-11-04 00:39:12.291 Juxta[60526:1144351] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[_TtCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7Counter parseClassName]: unrecognized selector sent to class 0x1059bb640'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000106c183f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000108746bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000106c1f40d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x0000000106b777fc ___forwarding___ + 988
    4   CoreFoundation                      0x0000000106b77398 _CF_forwarding_prep_0 + 120
    5   Juxta                               0x00000001057e2812 -[PFObject(Private) init] + 143
    6   Juxta                               0x00000001057d59f0 _TFCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7CountercfMS1_FT_S1_ + 64
    7   Juxta                               0x00000001057d5a32 _TFCFC5Juxta14ViewController11viewDidLoadFS0_FT_T_L_7CounterCfMS1_FT_S1_ + 50
    8   Juxta                               0x00000001057d44a7 _TFC5Juxta14ViewController11viewDidLoadfS0_FT_T_ + 1575
    9   Juxta                               0x00000001057d47f2 _TToFC5Juxta14ViewController11viewDidLoadfS0_FT_T_ + 34
    10  UIKit                               0x00000001075c7190 -[UIViewController loadViewIfRequired] + 738
    11  UIKit                               0x00000001075c738e -[UIViewController view] + 27
    12  UIKit                               0x00000001074e6db9 -[UIWindow addRootViewControllerViewIfPossible] + 58
    13  UIKit                               0x00000001074e7152 -[UIWindow _setHidden:forced:] + 276
    14  UIKit                               0x00000001074f365c -[UIWindow makeKeyAndVisible] + 42
    15  UIKit                               0x000000010749e191 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2628
    16  UIKit                               0x00000001074a0e5c -[UIApplication _runWithMainScene:transitionContext:completion:] + 1350
    17  UIKit                               0x000000010749fd22 -[UIApplication workspaceDidEndTransaction:] + 179
    18  FrontBoardServices                  0x000000010c3472a3 __31-[FBSSerialQueue performAsync:]_block_invoke + 16
    19  CoreFoundation                      0x0000000106b4dabc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    20  CoreFoundation                      0x0000000106b43805 __CFRunLoopDoBlocks + 341
    21  CoreFoundation                      0x0000000106b435c5 __CFRunLoopRun + 2389
    22  CoreFoundation                      0x0000000106b42a06 CFRunLoopRunSpecific + 470
    23  UIKit                               0x000000010749f799 -[UIApplication _run] + 413
    24  UIKit                               0x00000001074a2550 UIApplicationMain + 1282
    25  Juxta                               0x00000001057d6e7e top_level_code + 78
    26  Juxta                               0x00000001057d6eba main + 42
    27  libdyld.dylib                       0x00000001097a8145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
以下是我的代码,以便更清楚:

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    var testObject = PFObject(className: "TestObject")
    testObject["foo"] = "bar"
    testObject.saveInBackgroundWithTarget(nil, selector: nil)

    class Counter : PFObject {
        var voteCount: Int = 0
        func incrementBy(amount: Int, numberOfTimes times: Int) { voteCount += amount * times
            println(" \(voteCount) votes")
        }
    }

    var countOption1 = PFObject(className: "countOption1")
        countOption1 = Counter()
        countOption1.saveInBackgroundWithTarget(PFObject.self, selector: nil)

}





override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

我的代码有什么问题吗?这次我非常小心。

你一定是在复制和粘贴时出错了。例如,没有理由认为:

类计数器在UIViewController中定义

类计数器具有didReceiveMemoryWarning函数

countOption1函数中的另一个类计数器


这是一个混乱

了解如何正确格式化代码。我刚刚正确格式化了代码,但现在我得到了一个全新的错误,正如我在上面编辑的。你明白无法识别的选择器的含义吗?这意味着您已导致将parseClassName方法发送到无法识别它的类。读Swift堆栈跟踪有点难,但可能在Juxta14ViewController中,您创建了一个PFObject,并将错误的参数传递给了Counter类的一个实例,我认为。除非Swift比我认为的更难理解,否则您似乎要对countOption1进行双重赋值。我怀疑countOption1=Counter是假的。如果你对编程原理的理解达到这个水平,你真的不应该用Swift编程。Objective-C不是初学者的语言,Swift更糟糕,因为它的文档记录很差,而且有缺陷。请考虑切换到java/Android。我刚重新格式化它,但是我得到了一个异常的异常错误,现在有什么问题?