2016-08-26 4 views
0

私のプログラムはこの問題を示しています。誰が何が間違っているのか教えていただけますか?NSUnknownKeyException - Xcode

"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) " 

のViewController:メッセージをエラー出力に

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 
    }*/ 

} 

答えて

2

ご注意:

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.' 

何かがあなたのビューコントローラの非存在imQuadroプロパティを設定しようとすると、スタックトレースからコンセントに言及おそらくコントローラがstoryboard/xibからロードされたときに起こります。

インターフェイスビルダーに間違ったコンセント接続が設定されている可能性があります。最初にコンセントを名前imQuadroで作成し、コード内で手動でimgQuadroに固定した場合に発生する可能性があります。

+0

どうすればいいですか?私は再び名前を変更し、エラーが続く。 :/ – Larissa

+0

あなたが持っているIBOutletの接続を確認してください。間違った名前のものがある場合は削除し、適切な名前のコンセントに接続してください – Vladimir

関連する問題