小编Iva*_*van的帖子

表达式类型'(_,_ .tride) - > _'是不明确的,没有更多的上下文

救命!我遇到错误'表达式类型'(_,_.Stride) - > _'是不明确的,没有更多的上下文'.有谁知道为什么会这样,并有解决方案吗?我使用的是Swift 4.
代码:

let offsetTime = 0
DispatchQueue.main.asyncAfter(deadline: .now() + offsetTime) { //Expression type '(_, _.Stride) -> _' is ambiguous without more context
    self.currentTaskForUser.text = "Starting\n" + note +  "in"
    self.timerDown(from: 3, to: 1)
}
DispatchQueue.main.asyncAfter(deadline: .now() + offsetTime + 3) { //Expression type '(_, _.Stride) -> _' is ambiguous without more context
    self.currentTaskForUser.text = note
    let difficultyValue = Int(self.difficultyControl.titleForSegment(at: self.difficultyLevel.selectedSegmentIndex)!)!
    self.timerUp(from: 1, to: difficultyValue)
    self.offsetTime += 13
}
Run Code Online (Sandbox Code Playgroud)

swift swift4

5
推荐指数
1
解决办法
1919
查看次数

如何访问 python 数据类中默认参数中的另一个参数?

我试图导出id_from的默认值name,反之亦然。

@dataclass
class Item:
    id_ = NAME_TO_ID[name]
    name = ID_TO_NAME[id_]
Run Code Online (Sandbox Code Playgroud)

我应该能够像这样调用该类:

Item(id_=123)
Item(name='foo')
Run Code Online (Sandbox Code Playgroud)

如果可能的话,我还希望类在提供id_和时引发错误。name

Item(id_=123, name='foo')  # ValueError: id_ and name cannot be provided together
Run Code Online (Sandbox Code Playgroud)

关于我应该如何去做这件事有什么建议吗?

python python-3.7 python-dataclasses

5
推荐指数
1
解决办法
877
查看次数

“ #selector”的参数未引用“ @objc”方法,属性或初始化程序

谁能告诉我为什么此代码给出错误消息“'#selector'的参数不引用'@objc'方法,属性或初始化程序”吗?

timer = Timer.scheduledTimer(timeInterval: 0.1, target: self, selector:#selector(updateTimer(until: 3)), userInfo: nil, repeats: true)   
Run Code Online (Sandbox Code Playgroud)

功能如下:

func updateTimer(until endTime: Int) { 
    counter -= 1
    timeLabel.text = String(counter)
    if counter == endTime {
        step += 1
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试了什么:
1.在函数前面添加@objc。

selector swift swift3

4
推荐指数
1
解决办法
8268
查看次数

如何从Swift 4降级到Swift 3?

我刚刚将我的代码从Swift 3升级到Swift 4.后来,我改变主意,想在iOS 10中使用我的代码.然后我收到了这个错误:

对于使用Swift的目标,需要正确配置"Swift语言版本"(SWIFT_VERSION).使用[Edit> Convert> To Current Swift Syntax ...]菜单选择Swift版本或使用Build Settings编辑器直接配置构建设置.

我使用[编辑>转换>到当前Swift语法...]菜单来选择Swift版本,但随后它说

'没有过滤结果'.

然后,我尝试使用Build Settings并将'SWIFT_VERSION'从4.0更改为3.1以及3.0.但是,错误仍然存​​在.有谁知道解决这个问题?提前致谢!

swift swift3 swift4

4
推荐指数
1
解决办法
5912
查看次数