gpt4 book ai didi

swift - NSUnknownKeyException - Xcode

转载 作者:行者123 更新时间:2023-11-28 12:42:10 34 4
gpt4 key购买 nike

我的程序显示了这个问题。谁能告诉我哪里出了问题?

"2016-08-26 17:21:00.548 SegundaTentativa[2347:203583] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SegundaTentativa.ViewController 0x7f9749d188d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imQuadro.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010786dd85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000109611deb objc_exception_throw + 48
2 CoreFoundation 0x000000010786d9c9 -[NSException raise] + 9
3 Foundation 0x0000000107c3f19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288
4 UIKit 0x0000000108228d0c -[UIViewController setValue:forKey:] + 88
5 UIKit 0x000000010845f7fb -[UIRuntimeOutletConnection connect] + 109
6 CoreFoundation 0x00000001077a7890 -[NSArray makeObjectsPerformSelector:] + 224
7 UIKit 0x000000010845e1de -[UINib instantiateWithOwner:options:] + 1864
8 UIKit 0x000000010822f8d6 -[UIViewController _loadViewFromNibNamed:bundle:] + 381
9 UIKit 0x0000000108230202 -[UIViewController loadView] + 178
10 UIKit 0x0000000108230560 -[UIViewController loadViewIfRequired] + 138
11 UIKit 0x0000000108230cd3 -[UIViewController view] + 27
12 UIKit 0x0000000108106fb4 -[UIWindow addRootViewControllerViewIfPossible] + 61
13 UIKit 0x000000010810769d -[UIWindow _setHidden:forced:] + 282
14 UIKit 0x0000000108119180 -[UIWindow makeKeyAndVisible] + 42
15 UIKit 0x000000010808ded9 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
16 UIKit 0x0000000108094568 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1769
17 UIKit 0x0000000108091714 -[UIApplication workspaceDidEndTransaction:] + 188
18 FrontBoardServices 0x000000010b4a28c8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
19 FrontBoardServices 0x000000010b4a2741 -[FBSSerialQueue _performNext] + 178
20 FrontBoardServices 0x000000010b4a2aca -[FBSSerialQueue _performNextFromRunLoopSource] + 45
21 CoreFoundation 0x0000000107793301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x000000010778922c __CFRunLoopDoSources0 + 556
23 CoreFoundation 0x00000001077886e3 __CFRunLoopRun + 867
24 CoreFoundation 0x00000001077880f8 CFRunLoopRunSpecific + 488
25 UIKit 0x0000000108090f21 -[UIApplication _run] + 402
26 UIKit 0x0000000108095f09 UIApplicationMain + 171
27 SegundaTentativa 0x0000000107688432 main + 114
28 libdyld.dylib 0x000000010a0d592d start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) "

View Controller :

import UIKit

class ViewController: UIViewController {


@IBOutlet weak var lbTexto: UILabel!


@IBOutlet weak var imgQuadro: UIImageView!


override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
lbTexto.text = "Que jogador de vôlei e?"
}

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


@IBAction func ChangeText(sender: AnyObject) {
lbTexto.text = "Ricardinho"
}


@IBAction func HiddenQuadro(sender: AnyObject) {
imgQuadro.hidden = true
}


/*@IBAction func TesteSimbora(sender: UIButton) {
lbText.text = "Ricardinho"
}

@IBAction func EscondeQuadro(sender: UIButton) {
imQuadro.hidden = true
}*/

}

最佳答案

注意错误信息:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SegundaTentativa.ViewController 0x7f9749d188d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key imQuadro.'

有些东西试图设置 View Controller 的不存在的 imQuadro 属性,并且从堆栈跟踪中提到的导出,它可能发生在 Controller 从 Storyboard/xib 加载时。

很可能您在界面生成器中设置了错误的导出连接,如果您最初创建名称为 imQuadro 的导出然后手动将其修复为 imgQuadro 仅在您的代码。

关于swift - NSUnknownKeyException - Xcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39174239/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com