所以我通过在线发现的教程制作了一个简单的秒表应用程序。我按照ford的代码字创建了一个用于连接它的UI。 但是,每当我尝试运行程序时,iOS模拟器都无法通过显示应用程序名称的屏幕。然后它产生了大量的代码,并强调了这一点:
class AppDelegate: UIResponder, UIApplicationDelegate {`
表示THREAD 1: signal SIGABRT
这是什么意思?
同样在控制台中我收到此消息:
(提前为大量代码道歉,标记它似乎不起作用)
2015-06-15 15:53:54.313 stopwatch2[20524:1296474] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<stopwatch2.ViewController 0x7f9280476960> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key display.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010fcecc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111857bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010fcec8a9 -[NSException raise] + 9
3 Foundation 0x000000011010ab53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x000000010fc34d50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000011086352b -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x00000001106bb718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x00000001106bbd08 -[UIViewController loadView] + 109
8 UIKit 0x00000001106bbf79 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x00000001106bc40e -[UIViewController view] + 27
10 UIKit 0x00000001105d72c9 -[UIWindow addRootViewControllerViewIfPossible] + 58
11 UIKit 0x00000001105d768f -[UIWindow _setHidden:forced:] + 247
12 UIKit 0x00000001105e3e21 -[UIWindow makeKeyAndVisible] + 42
13 UIKit 0x0000000110587457 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2732
14 UIKit 0x000000011058a1de -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
15 UIKit 0x00000001105890d5 -[UIApplication workspaceDidEndTransaction:] + 179
16 FrontBoardServices 0x00000001133675e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
17 CoreFoundation 0x000000010fc2041c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18 CoreFoundation 0x000000010fc16165 __CFRunLoopDoBlocks + 341
19 CoreFoundation 0x000000010fc15f25 __CFRunLoopRun + 2389
20 CoreFoundation 0x000000010fc15366 CFRunLoopRunSpecific + 470
21 UIKit 0x0000000110588b42 -[UIApplication _run] + 413
22 UIKit 0x000000011058b900 UIApplicationMain + 1282
23 stopwatch2 0x000000010faf0ff7 main + 135
24 libdyld.dylib 0x0000000111faf145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
但是,这是我的实际代码:
import UIKit
class ViewController: UIViewController {
var timer = NSTimer()
var count = 0
func updateTime() {
count++
time.text = "\(count)"
}
@IBOutlet var time: UILabel!
@IBAction func pause(sender: AnyObject) {
timer.invalidate()
}
@IBAction func stop(sender: AnyObject) {
timer.invalidate()
count = 0
time.text = "0"
}
@IBAction func start(sender: AnyObject) {
timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("updateTime"),userInfo: nil, repeats: true)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
有人请帮忙吗?
答案 0 :(得分:0)
You probably connected an object called display
to your View Controller, but then removed/changed the property in the source code.
You have to go to your controller in the Storyboard, click the outlets icon and delete the display
outlet, it will have an exclamation mark.