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

标签 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) 

最佳答案

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

关于ios - 当我尝试运行此页面时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27595214/

相关文章:

iphone - MPMoviePlayerViewController 问题-Iphone

swift - 字典用 .keys 改变索引位置——Swift

r - emdist 段错误中的 emd2d 函数

ios - 无法在 Storyboard 中的捆绑错误中加载 NIB

ios - 反转基于描边的 CALayer 蒙版(无填充)

ffmpeg - TCL 命令提示符在 tcl 版本 8.0 和窗口 7 中崩溃,出现错误 "ffmpeg.exe stopped working"

ios - MFMessageComposeViewController 将 SMS 正文中的完整 URL 链接替换为 "clickable"文本

iphone - 在动画期间访问 UIView 的当前位置

iphone - ios sdk 中的促销代码是什么?我们为什么使用它们?

ios - 为什么使用 NSLayoutConstraint.activate 比 .isActive = true 更有效?