gpt4 book ai didi

快速错误: Consecutive declarations on a line must be separated by ';'

转载 作者:行者123 更新时间:2023-11-30 10:14:34 33 4
gpt4 key购买 nike

这是我的代码:

import UIKit

class PlaylistMasterViewController: UIViewController {

@IBOutlet weak var abutton: UIButton!

override func viewDidLoad() {
super.viewDidLoad()

abutton.setTitle("Press me!", forState: .Normal)


}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showPlaylistDetailSegue" {
let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController

playlistDetailController.segueLabelText = "Yay!You Pressed"
}


}

我在最后一行遇到错误!我的 xCode 版本是 6.3.2 .. 我无法克服这个问题,因为应用程序总是失败。我在这里遇到两个错误:1- 一行中的连续声明必须用“;”分隔2- 预期声明

提前致谢

最佳答案

您缺少结束括号来结束您的类(class),我通过在每次打开和关闭括号时添加注释来演示这一点,例如:

if myVar == 1 { //OPEN: 1
//do something
} //CLOSE: 1

1 只是一种跟踪哪个括号是哪个的方法,所以如果你有多个括号(你确实这样做了),你会看到类似的东西

//OPEN: 2 and //CLOSE: 2

我在下面添加了您的代码,显示您的括号何时打开和关闭。

import UIKit

class PlaylistMasterViewController: UIViewController { //OPEN: 1

@IBOutlet weak var abutton: UIButton!

override func viewDidLoad() { //OPEN: 2
super.viewDidLoad()
abutton.setTitle("Press me!", forState: .Normal)
} //CLOSE: 2 -- 1 still needs to be closed

override func didReceiveMemoryWarning() { //OPEN: 3
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
} //CLOSE: 3 -- 1 still needs to be closed

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { //OPEN: 4
if segue.identifier == "showPlaylistDetailSegue" { //OPEN: 5
let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController
playlistDetailController.segueLabelText = "Yay!You Pressed"
} //CLOSE: 5 -- 1 & 4 still need to be closed
} //CLOSE: 4 -- 1 still needs to be closed

// This is where you need to close 1, you're missing the bracket under this comment

} //ADD ME -- CLOSE: 1 -- no brackets to close left

我希望您现在能更清楚一点。请正确练习缩进代码,这样可以节省大量调试此类简单错误的时间! :)

关于快速错误: Consecutive declarations on a line must be separated by ';' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30965893/

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