Swift 将indexOf()与UIButton类型的数组一起使用
我正在这个链接上学习一个名为“开始开发iOS应用程序(Swift)”的教程 据我所知,我完全按照教程进行了学习,对于下面代码块中最后一行代码的问题感到困惑Swift 将indexOf()与UIButton类型的数组一起使用,swift,uibutton,indexof,Swift,Uibutton,Indexof,我正在这个链接上学习一个名为“开始开发iOS应用程序(Swift)”的教程 据我所知,我完全按照教程进行了学习,对于下面代码块中最后一行代码的问题感到困惑 var ratingButtons = [UIButton]() ... // MARK: Button Action func ratingButtonTapped(button: UIButton){ //print("Button pressed T
var ratingButtons = [UIButton]()
...
// MARK: Button Action
func ratingButtonTapped(button: UIButton){
//print("Button pressed That tutorial is about Swift 2.0. indexOf
exists in Swift 2.0. You are using Swift 1.2, so it doesn't exist for you. Update to Xcode 7 so you can use Swift 2.0.indexOf was created as of Swift 2.0. YOU DON'T need to update your Xcode, just use the find
method,
rating = find(ratingButtons, button)! + 1
var ratingbutton=[UIButton]()
...
//标记:按钮动作
功能分级按钮已标记(按钮:UIButton){
//印刷品("按下按钮该教程是关于Swift 2.0的。indexOf
存在于Swift 2.0中。您正在使用Swift 1.2,因此它不存在。更新到Xcode 7,以便您可以使用Swift 2.0。该教程是关于Swift 2.0的。indexOf
存在于Swift 2.0中。您正在使用Swift 1.2,因此它不存在。更新到Xcode 7,以便您可以使用Swift 2.0。indexOf是从Swift 2.0开始创建的。您不需要更新Xcode,只需使用find
方法
indexOf是从Swift 2.0开始创建的。您不需要更新Xcode,只需使用find
方法