【问题标题】:consecutive declarations on a line must be separated by ';' [closed]一行上的连续声明必须用';'分隔[关闭]
【发布时间】:2017-02-03 05:11:32
【问题描述】:

我在 Swift 3.0 的 xCode 中创建表格视图,但这个错误一直出现。当我用另一个';'修复它时,它会显示另一个错误“预期声明”。 谁能帮我解决这个问题?

【问题讨论】:

    标签: xcode swift3


    【解决方案1】:

    Swift 中的返回类型运算符是 -> 而不是 -&gt 可能是您从浏览器或其他地方复制和粘贴代码,所以只需将其替换为 ->。同样在 Swift 3 中,这些方法的签名也发生了变化,所以应该是这样的。

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return UITableViewCell()
    }
    

    【讨论】:

    • 我是 Swift 新手。谢谢你帮我修好了!!
    • @windc 欢迎朋友 :) 请记住,这将填充空的 tableView :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多