gpt4 book ai didi

ios - 秒表应用程序不断崩溃

转载 作者:行者123 更新时间:2023-11-30 14:18:14 25 4
gpt4 key购买 nike

所以我正在通过我在网上找到的教程制作一个简单的秒表应用程序。我遵循福特的代码并创建了一个用户界面来连接到它。然而,每当我尝试运行该程序时,iOS 模拟器都无法通过显示应用程序名称的屏幕。然后它会生成大量代码,并突出显示这一点:

class AppDelegate: UIResponder, UIApplicationDelegate {`

其下声明THREAD 1:信号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()
}
}

有人可以帮忙吗?

最佳答案

您可能将一个名为 display 的对象连接到 View Controller ,但随后在源代码中删除/更改了该属性。

您必须转到 Storyboard 中的 Controller ,单击 socket 图标并删除 display socket ,它将带有感叹号。

关于ios - 秒表应用程序不断崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30856539/

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