我目前正在尝试将应用从4个tableviews缩减为2个分段的tableviews(第二个tableview代码未完成), 但是,一旦我为第一个视图控制器更改了segue,以便它接收到帐户部分我不断收到此错误“使用未解析的标识符'索引路径'”
视图控制器1的代码
FileOutputStream fos = openFileInput(FILENAME, Context.MODE_PRIVATE);.
视图控制器2的代码
if let indexPath = tableView.indexPathForSelectedRow
class FirstTableViewController: UITableViewController{
//MakesModel
struct MakeModel {
var Make : String!
var model : [String]!
}
var FirstTableArray = [MakeModel]()
//YearsEngine
var SecondArray = [SecondTable]()
//Data final output
var ThirdArray = [ThirdView]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Makesmodels
FirstTableArray = [MakeModel(Make: "Audi", model: ["A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8"]),MakeModel(Make: "BMW", model: ["1 Series", "2 Series", "3 Series", "4 Series", "5 Series", "6 Series", "7 Series", "8 Series"]),MakeModel(Make: "Nissan", model: ["Almera", "Cube", "GTR", "Juke", "Micra", "Navara", "Note", "Qashqai"]),MakeModel(Make: "Honda", model: ["Accord", "Civic", "CR-V", "CR-Z", "Integra", "Jazz", "NSX", "S2000"])]
//YearsEngine
SecondArray =
[SecondTable(SecondTitle: ["A1","A2","A3"]),
SecondTable(SecondTitle: ["Civic","NSX","Jazz"]),
SecondTable(SecondTitle: ["Note","Qashqai","GTR;)"]),
SecondTable(SecondTitle: ["Focus"])]
// imformation DATA final output
ThirdArray = [ThirdView(ThirdViewArray: ["asdkljf","asdfasd","asdfas"]),
ThirdView(ThirdViewArray: ["asdkljf","asdfasd","asdfas"]),
ThirdView(ThirdViewArray: ["asdkljf","asdfasd","asdfas"]),
ThirdView(ThirdViewArray: ["asdkljf"])]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return FirstTableArray[section].model.count
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return FirstTableArray.count
}
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return FirstTableArray[section].Make
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let Cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
Cell.textLabel?.text = FirstTableArray[indexPath.section].model[indexPath.row]
return Cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let row = self.tableView.indexPathForSelectedRow!.row
let section = self.tableView.indexPathForSelectedRow!.section
var DestViewController = segue.destinationViewController as! SecondTableViewController
var SecondTableArrayTwo : SecondTable
SecondTableArrayTwo = SecondArray[indexpath.row]
DestViewController.SecondArray = SecondTableArrayTwo.SecondTitle
}
}
欢迎任何帮助