2015-11-03 29 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…