切换语句...案例后的预期模式:

Mar*_*oon -1 ios swift3

在switch语句中的每个case声明之后,XCode指示应该有一个预期的模式吗?

override func prepare(for segue: UIStoryboardSegue, sender: Any?)  {
    switch segue.identifier {
    case: "SegueToCommentRating"
            let commentRatingViewController = segue.destination as! CommentRatingViewController
            commentRatingViewController.post = self.post
            commentRatingViewController.delegate = self
    case: "SegueToLogin"
            let loginViewController = segue.destination as! LoginViewController
            loginViewController.managedObjectContext = managedObjectContext
    case: "SegueToEditCommentOrRating"
            let commentRatingViewController = segue.destination as! CommentRatingViewController
            commentRatingViewController.post = self.post
            commentRatingViewController.userWillEdit = true
            commentRatingViewController.delegate = self
    default:
        break
    }
}
Run Code Online (Sandbox Code Playgroud)

错误图片: 在此处输入图片说明

编辑:我已经尝试了建议(移动:)我收到另一个奇怪的错误,如下图所示: 在此处输入图片说明

Ale*_*ang 5

正确的代码是:

 override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if let string = segue.identifier {
            switch string {
            case "SegueToCommentRating":
                let commentRatingViewController = segue.destination as! CommentRatingViewController
                commentRatingViewController.post = self.post
                commentRatingViewController.delegate = self
            case "SegueToLogin":
                let loginViewController = segue.destination as! LoginViewController
                loginViewController.managedObjectContext = managedObjectContext
            case "SegueToEditCommentOrRating":
                let commentRatingViewController = segue.destination as! CommentRatingViewController
                commentRatingViewController.post = self.post
                commentRatingViewController.userWillEdit = true
                commentRatingViewController.delegate = self
            default:
                break
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

只需将“:”移到要比较的值之后