我尝试运行此页面时应用程序崩溃

时间:2014-12-22 00:18:04

标签: ios swift crash textview

我的应用程序构建并成功运行,其他页面没有任何问题。此页面成功构建,但是,当我尝试转到页面时,应用程序将崩溃。我不确定如何解决这个问题。

import UIKit

class ViewController: UIViewController
{

    @IBOutlet weak var txtView: UITextView!

    func loadData (){

        var txtView: NSMutableArray = NSMutableArray ()
        txtView.removeAllObjects()

        var query = PFQuery(className:"NewsPages")

        query.getObjectInBackgroundWithId("KerL5Xf0Bx")
            {

            (NewsPages: PFObject!, error: NSError!) -> Void in
            if error == nil
            {
                let content = NewsPages["content"] as String

                self.txtView.text = String()

            }
            else
            {
                NSLog("%@", error)
            }


        }
    }
}

我的错误代码:

2014-12-21 20:00:05.679 App[1707:84302] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<App.ViewController 0x7fab1a4aabf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key GameScore.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010b649f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010d18dbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010b649b79 -[NSException raise] + 9
    3   Foundation                          0x000000010ba617b3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
    4   CoreFoundation                      0x000000010b593e80 -[NSArray makeObjectsPerformSelector:] + 224
    5   UIKit                               0x000000010c19ac7d -[UINib instantiateWithOwner:options:] + 1506
    6   UIKit                               0x000000010bff9f98 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
    7   UIKit                               0x000000010bffa588 -[UIViewController loadView] + 109
    8   UIKit                               0x000000010bffa7f9 -[UIViewController loadViewIfRequired] + 75
    9   UIKit                               0x000000010bffac8e -[UIViewController view] + 27
    10  UIKit                               0x000000010c59c41e -[_UIFullscreenPresentationController _setPresentedViewController:] + 65
    11  UIKit                               0x000000010bfd6429 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 105
    12  UIKit                               0x000000010c006a41 -[UIViewController _presentViewController:withAnimationController:completion:] + 1746
    13  UIKit                               0x000000010c008d81 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 132
    14  UIKit                               0x000000010c008ca5 -[UIViewController presentViewController:animated:completion:] + 229
    15  UIKit                               0x000000010bed68be -[UIApplication sendAction:to:from:forEvent:] + 75
    16  UIKit                               0x000000010bfdd410 -[UIControl _sendActionsForEvents:withEvent:] + 467
    17  UIKit                               0x000000010bfdc7df -[UIControl touchesEnded:withEvent:] + 522
    18  UIKit                               0x000000010bf1c308 -[UIWindow _sendTouchesForEvent:] + 735
    19  UIKit                               0x000000010bf1cc33 -[UIWindow sendEvent:] + 683
    20  UIKit                               0x000000010bee99b1 -[UIApplication sendEvent:] + 246
    21  UIKit                               0x000000010bef6a7d _UIApplicationHandleEventFromQueueEvent + 17370
    22  UIKit                               0x000000010bed2103 _UIApplicationHandleEventQueue + 1961
    23  CoreFoundation                      0x000000010b57f551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000010b57541d __CFRunLoopDoSources0 + 269
    25  CoreFoundation                      0x000000010b574a54 __CFRunLoopRun + 868
    26  CoreFoundation                      0x000000010b574486 CFRunLoopRunSpecific + 470
    27  GraphicsServices                    0x000000010e6e09f0 GSEventRunModal + 161
    28  UIKit                               0x000000010bed5420 UIApplicationMain + 1282
    29  Mars App                            0x000000010a21d98e top_level_code + 78
    30  Mars App                            0x000000010a21da6a main + 42
    31  libdyld.dylib                       0x000000010e1f0145 start + 1
    32  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

2 个答案:

答案 0 :(得分:1)

打开相应的xib文件检查所有UI插座连接,在那里你可以看到某些连接中的警告。删除那个。

答案 1 :(得分:0)

此错误始终是您的xib文件绑定错误或不存在的方法,因此当您加载视图控制器失败时。检查您的xib文件

相关问题