I have problem with my code. Can anyone help me please?
Error: 2015-12-10 19:57:58.890 time[1177:36084] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<time.ViewController 0x79122de0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key display.' *** First throw call stack: ( 0 CoreFoundation 0x001fea14 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x01eafe02 objc_exception_throw + 50 2 CoreFoundation 0x001fe631 -[NSException raise] + 17 3 Foundation 0x006501bc -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282 4 Foundation 0x005aa83a _NSSetUsingKeyValueSetter + 115 5 Foundation 0x005aa7bf -[NSObject(NSKeyValueCoding) setValue:forKey:] + 295 6 UIKit 0x00ba306d -[UIViewController setValue:forKey:] + 85 7 Foundation 0x005df01d -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 384 8 UIKit 0x00e16cb4 -[UIRuntimeOutletConnection connect] + 132 9 libobjc.A.dylib 0x01ec400c -[NSObject performSelector:] + 62 10 CoreFoundation 0x0012ef51 -[NSArray makeObjectsPerformSelector:] + 273 11 UIKit 0x00e1534e -[UINib instantiateWithOwner:options:] + 2102 12 UIKit 0x00baaabc -[UIViewController _loadViewFromNibNamed:bundle:] + 429 13 UIKit 0x00bab4f4 -[UIViewController loadView] + 189 14 UIKit 0x00bab900 -[UIViewController loadViewIfRequired] + 154 15 UIKit 0x00bac1ed -[UIViewController view] + 35 16 UIKit 0x00a59f94 -[UIWindow addRootViewControllerViewIfPossible] + 69 17 UIKit 0x00a5a6b1 -[UIWindow _setHidden:forced:] + 304 18 UIKit 0x00a5aa67 -[UIWindow _orderFrontWithoutMakingKey] + 49 19 UIKit 0x00a6e118 -[UIWindow makeKeyAndVisible] + 80 20 UIKit 0x009d66e7 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4190 21 UIKit 0x009ddcd6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1989 22 UIKit 0x00a02ee5 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3218 + 68 23 UIKit 0x009da966 -[UIApplication workspaceDidEndTransaction:] + 163 24 FrontBoardServices 0x03c37c76 __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71 25 FrontBoardServices 0x03c3774d __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54 26 FrontBoardServices 0x03c55173 -[FBSSerialQueue _performNext] + 184 27 FrontBoardServices 0x03c555aa -[FBSSerialQueue _performNextFromRunLoopSource] + 52 28 FrontBoardServices 0x03c548a6 FBSSerialQueueRunLoopSourceHandler + 33 29 CoreFoundation 0x001186ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 30 CoreFoundation 0x0010e38b __CFRunLoopDoSources0 + 523 31 CoreFoundation 0x0010d7a8 __CFRunLoopRun + 1032 32 CoreFoundation 0x0010d0e6 CFRunLoopRunSpecific + 470 33 CoreFoundation 0x0010cefb CFRunLoopRunInMode + 123 34 UIKit 0x009da206 -[UIApplication _run] + 540 35 UIKit 0x009dfbfa UIApplicationMain + 160 36 time 0x0001940c main + 140 37 libdyld.dylib 0x02913a21 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
and my code is:
//
// ViewController.swift
// time
//
// Created by Marek on 09.12.15.
// Copyright © 2015 Marek. All rights reserved.
//
import CoreFoundation
import CoreGraphics
import Darwin
import Foundation
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var currentTimeLabel: UILabel!
var timer = NSTimer()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.timer = NSTimer.scheduledTimerWithTimeInterval(
1.0,
target: self,
selector: Selector("tick"),
userInfo: nil,
repeats: true)
}
@objc func tick() {
currentTimeLabel.text = NSDateFormatter.localizedStringFromDate(NSDate(),
dateStyle: .MediumStyle,
timeStyle: .MediumStyle)
}
}