gpt4 book ai didi

ios - 无法识别的选择器发送到实例 0x7f995be07650

转载 作者:行者123 更新时间:2023-11-30 11:17:31 26 4
gpt4 key购买 nike

我有最新更新的 Xcode。我刚刚开始学习 swift,但遇到错误。请帮忙。谢谢

2018-07-31 06:30:29.085754+1200 swift4[2874:61277] -[swift4.ViewController uda1]: unrecognized selector sent to instance 0x7fe13f6122a02018-07-31 06:30:29.089728+1200 swift4[2874:61277] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[swift4.ViewController uda1]: unrecognized selector sent to instance 0x7fe13f6122a0'*** First throw call stack:(    0   CoreFoundation                      0x0000000102dfd1e6 __exceptionPreprocess + 294    1   libobjc.A.dylib                     0x0000000102492031 objc_exception_throw + 48    2   CoreFoundation                      0x0000000102e7e784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132    3   UIKit                               0x00000001034a86db -[UIResponder doesNotRecognizeSelector:] + 295    4   CoreFoundation                      0x0000000102d7f898 ___forwarding___ + 1432    5   CoreFoundation                      0x0000000102d7f278 _CF_forwarding_prep_0 + 120    6   Foundation                          0x0000000101efc4dd __NSFireTimer + 83    7   CoreFoundation                      0x0000000102d8ce64 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20    8   CoreFoundation                      0x0000000102d8ca52 __CFRunLoopDoTimer + 1026    9   CoreFoundation                      0x0000000102d8c60a __CFRunLoopDoTimers + 266    10  CoreFoundation                      0x0000000102d83e4c __CFRunLoopRun + 2252    11  CoreFoundation                      0x0000000102d8330b CFRunLoopRunSpecific + 635    12  GraphicsServices                    0x00000001089d1a73 GSEventRunModal + 62    13  UIKit                               0x000000010327a057 UIApplicationMain + 159    14  swift4                              0x0000000101b86927 main + 55    15  libdyld.dylib                       0x000000010720d955 start + 1)libc++abi.dylib: terminating with uncaught exception of type NSException(lldb) 

I'm getting error:

In my Viewcontroller:

import UIKit

class ViewController: UIViewController {
var timer1 = Timer()
var counter = 0

@IBOutlet weak var Label: UILabel!

@IBAction func Start(_ sender: Any) {
counter = 0
Label.text = String (counter)

timer1 = Timer.scheduledTimer(timeInterval: 1, target: self, selector: ("uda1") , userInfo: nil, repeats: true);
}

func uda1 ()
{
counter += 1
Label.text = String(counter)
}

@IBAction func Stop(_ sender: Any) {
timer1.invalidate()
}
}

最佳答案

你可以试试

 timer1 = Timer.scheduledTimer(timeInterval: 1, target: self, #selector(uda1) , userInfo: nil, repeats: true);

//

@objc func uda1()
{
counter += 1
Label.text = String(counter)

}

//

var timer1:Timer?

//

timer1?.invalidate()

关于ios - 无法识别的选择器发送到实例 0x7f995be07650,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51600217/

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