gpt4 book ai didi

ios - Xcode 7.3 更新后出现语法错误

转载 作者:行者123 更新时间:2023-11-30 13:35:08 27 4
gpt4 key购买 nike

昨天我安装了新的 Xcode 7.3,我的问题开始了。

我必须对 swift 3 进行许多更改。我通过 Xcode 的“自动更正”解决了许多更改。

但是有两件事无法自动解决:

问题 1 enter image description here

问题2

 for ( var x = 1; x < self.ACData.count; x ++ ) {

但我应该这样做:

enter image description here

如果我应用更正,我会得到以下结果:

for ( x in 2 ..< self.ACData.count ) {

这使我出现语法错误。有人可以帮我吗? :)

更新

let app:UIApplication = UIApplication.sharedApplication()
for oneEvent in app.scheduledLocalNotifications! {
let notification: AnyObject = oneEvent
let userInfoCurrent = notification.userInfo as! [NSObject: AnyObject]
if userInfoCurrent["UUID"] == nil {
app.cancelLocalNotification(notification as! UILocalNotification)
}
}

最佳答案

问题 1:

不要沮丧,没有必要。您可以为 NSObject 输入一个字符串,因此只需编写以下内容:

let userInfoCurrent = notification.userInfo!

问题2:

去掉括号。这确实是修复它所要做的全部事情,不要写:

for ( x in 2 ..< self.ACData.count )

这不是正确的快速方式,它应该是:

for x in 2 ..< self.ACData.count {

更新:

根据上面显示的代码,我认为最好的方法是:

let app:UIApplication = UIApplication.sharedApplication()
for oneEvent in app.scheduledLocalNotifications! {
let notification: AnyObject = oneEvent
guard let userInfoCurrent = notification.userInfo,
let uuid = userInfoCurrent["UUID"] else {
app.cancelLocalNotification(notification as! UILocalNotification)
return //or continue, don't know if you want to keep looping after this
}
// Do something with UUID if it's not necessary you can update the code as follows:
// guard let userInfoCurrent = notification.userInfo where userInfoCurrent["UUID"] != nil else {
}

我希望这能起作用

关于ios - Xcode 7.3 更新后出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36172078/

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