2016-07-18 21 views
-4

我是一名代码初学者。对于我的第一个应用程序,我试图包装一个代码,让我在不同的表格中显示不同的数据。表格数据Swift

我不明白为什么Xcode不断通知我这个错误:预期的声明。有人能帮我解决这个问题吗?

非常感谢。

// 
// ViewController.swift 
// Tot_Forum 
// 
// Created by Fausto Saltetti on 18/07/16. 
// Copyright (c) 2016 Fausto Saltetti. All rights reserved. 
// 

import UIKit 

class FirtTableViewController: UITableViewController { 

var FirstTableArray = [String]() 

var SecondArray = [SecondTable]() 

override func viewDidLoad() { 
    super.viewDidLoad() 
    // Do any additional setup after loading the view, typically from a nib. 
    FirstTableArray = ["Focus on learning", "Participate and network", "Access and build knowledge", "Assess, reflect, evaluate", "Inspire and generate ideas", "Problem solve and plan", "Map ideas and relationships"] 

    SecondArray = 
     [SecondTable(SecondTitle: ["After Action Review","Audience Response Systems","Blogs","Case Studies", "Discussion Forums UPDATE","Jigsaw","Peer Assist", "Podcasting","Presentations", "Role Play", "Screencasting", "Social Networking", "Sociometrics"]), 
      SecondTable(SecondTitle: ["After Action Review","Audience Response Systems","Blogs","Case Studies", "Discussion Forums UPDATE","Jigsaw","Peer Assist", "Podcasting","Presentations", "Role Play", "Screencasting", "Social Networking", "Sociometrics"]), 
      SecondTable(SecondTitle: ["After Action Review","Audience Response Systems","Blogs","Case Studies", "Discussion Forums UPDATE","Jigsaw","Peer Assist", "Podcasting","Presentations", "Role Play", "Screencasting", "Social Networking", "Sociometrics"])] 

} 

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

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
    { 
    return FirstTableArray.count 
} 

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    var Cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell 
    Cell.textLabel?.text = FirstTableArray[indexPath.row] 
    return Cell 
} 

func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
    var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow()! 
    var DestViewController = segue.destinationViewController as! SecondTableViewController 
    var SecondTableArrayTwo : SecondTable? 
    SecondTableArrayTwo = SecondArray[indexPath.row] 
    DestViewController.SecondArray = SecondTableArrayTwo!.SecondTitle 

} // EXPECTED DECLARATION 
+0

你三重检查了*所有*括号是否正确匹配? - 你读过这个评论http://stackoverflow.com/questions/38431522/passing-data-between-table-views-using-structs-and-arrays-swift-xcode#comment64268937_38431522到你以前的问题? –

回答

2

如果该代码是您在该文件中的所有内容,那么您将缺少最后一个括号,即关闭该类的那个。最后加上}即可。

我的小格式会有所帮助。在Xcode中,您可以选择所有与一个然后CTRL缩进。这将为您设置代码格式,并且可以更容易地查看您缺少大括号的位置。