2015-11-03 85 views
0

我遇到了我的swift代码出现问题,我似乎无法弄清楚我已经找到答案,但没有找到与我相同问题的任何人。在范围内使用未解析的标识符

我的代码如下:

import UIKit 

class ViewController: UITableViewController{ 

    var subjects = [String]() 
    var defaultCell = "Cell" 


    override func viewDidLoad() { 
     super.viewDidLoad() 
    } 

    func subjectForDisplay(atIndexPath indexPath:NSIndexPath) { 
     if indexPath.section == 0 { 

      _ = subjects[indexPath.row] 
     } 
    } 

    override func viewWillAppear(animated: Bool) { 
     super.viewWillAppear(animated) 
     tableView.reloadData() 
    } 


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

    } 

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     if indexPath.section == 0 { 
      let cell = tableView.dequeueReusableCellWithIdentifier(defaultCell, forIndexPath: indexPath) as UITableViewCell 
      cell.textLabel?.text = subjects[indexPath.row] 
      return cell 

    } 

我在它给我的最后一个函数得到一个错误;未解决的识别符“defaultCell”和未解决的识别符使用的使用“主体”

+0

使用编辑器 - >结构 - >重新缩进(CTRL-I)在Xcode,你马上会看到问题... –

回答

1

卸下右大括号正上方func tableView(tableView: UITableView, cellForRowAtIndexPath…