ios - 升级到 xcode 7 后代码出现问题

标签 ios swift xcode6 xcode7


我有这段代码在 xcode6 上运行良好,升级到 xcode7 后出现以下错误

var levels:[(
                level: Int,
                activeButtons: [UIButton],
                numberOfButtons: Int,
                timer: [Int],
                blinks: [Int],
                score: [Int],
                subIndex: Int,
                image: String,
                bunce : Int,
                speed: Double

    )] = []
levels.append(level:1, activeButtons:[], numberOfButtons:2, timer:[0,10,8,5],blinks:[0,2,3,4], score:[0,100,150,200], subIndex: 0, image: "blue", bunce: 150, speed:0.6)

我收到的错误是

Cannot invoke 'append' with an argument list of type '(level: Int, activeButtons: [UIButton], numberOfButtons: Int, timer: [Int], blinks: [Int], score: [Int], subIndex: Int, image: String, bunce: Int, speed: Double)'
1. Expected an argument list of type '(Element)'

最佳答案

它需要在您要添加的元素周围加上另一个大括号...

    var levels:[(
    level: Int,
    activeButtons: [UIButton],
    numberOfButtons: Int,
    timer: [Int],
    blinks: [Int],
    score: [Int],
    subIndex: Int,
    image: String,
    bunce : Int,
    speed: Double


    )] = []


    levels.append((level:1, activeButtons:[], numberOfButtons:2, timer:[0,10,8,5],blinks:[0,2,3,4], score:[0,100,150,200], subIndex: 0, image: "blue", bunce: 150, speed:0.6))

关于ios - 升级到 xcode 7 后代码出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32680540/

相关文章:

ios - 在 UISplitViewController 中,无法使 showDetailViewController :sender: push onto detail navigationController

ios - 将事件指示器设置为 CollectionViewCell

ios - 从 UIScrollView 中删除 subview 并更新 View

cocoa - NSTextField 和自动布局 : Autogrow height -> Programmatically

ios - 在 UIsplitView 中更改主按钮的标题

ios - Facebook iOS SDK增加应用程序大小

ios - 如何从函数内部更改全局变量的值?

swift - 打印机不工作 TVOS - Swift

swift - 根据按钮请求在表格 View 中隐藏和显示部分

cocoa-touch - 基于用户输入的操作 Swift