gpt4 book ai didi

ios - Timer.scheduledTimer 在 swift 3 中不起作用

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

我的计时器不工作...谁能帮帮我?

如果用户登录成功,我使用计时器转换到下一页,但计时器不工作并且没有错误消息...

do {
if let convertedJsonIntoDict = try JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary {
// Print out dictionary
print("convertedJsonIntoDict=\(convertedJsonIntoDict)")
print("convertedJsonIntoDict.長度=\(convertedJsonIntoDict.count)")
// Get value by key
if convertedJsonIntoDict.count > 1{
let cc_account = convertedJsonIntoDict["Account"] as! String
self.NPaccount = cc_account
print("工號=\(self.NPaccount)")
let cc_account_2 = convertedJsonIntoDict["Account2"] as! String
self.Account = cc_account_2
print("帳號=\(self.Account)")
let cname = convertedJsonIntoDict["CName"] as! String
self.Name = cname
print("姓名=\(self.Name)")
self.Member.account = self.Account
self.Member.password = self.PasswordTextvield.text!
self.Member.npaccount = self.NPaccount
self.Member.name = self.Name
self.Member.uuid = self.UUID
self.Member.creatdate = self.now
print("Saving data to context...")
appDelegate.saveContext()
self.segueflag = true
EZLoadingActivity.hide(true, animated: true)
_ = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(self.nextBtn(sender:)), userInfo: nil, repeats: false)
}else{
self.segueflag = false
print("segueflag...\(self.segueflag)")
if !self.segueflag{
print("無此帳號資料...")
EZLoadingActivity.hide(false, animated: true)
//self.AccoubtTextvield.text = ""
//self.PasswordTextvield.text = ""
}
}
}
else{
print("here")
}
} catch let error as NSError {
print(error.localizedDescription)
}

@IBAction func nextBtn(sender: AnyObject) {
print("--------Go to next page!--------")
if members.count == 0{
SCLAlertView().showError("請先登入~~!!",subTitle:"")
return
}
if !segueflag{
SCLAlertView().showError("登入的帳號或密碼有誤~~!!",subTitle:"")
return
}
self.performSegue(withIdentifier: "login", sender: self)
}

谁能告诉我可能的答案。提前谢谢你....

最佳答案

Timer 方法在 ios10 中有所改变。如果您正在 checkin ios10,则可以使用以下代码。

   let systemVersion = UIDevice.current.systemVersion

if Int(systemVersion)! >= 10 {
_ = Timer.scheduledTimer(withTimeInterval: 1.5,
repeats: false) {
timer in
//Put the code that be called by the timer here.
print("Testing data")
}
}else{

_ = Timer.scheduledTimer(timeInterval: 1.5, target: self, selector: #selector(self.nextBtn(sender:)), userInfo: nil, repeats: false)

}

关于ios - Timer.scheduledTimer 在 swift 3 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43137380/

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