2015-10-01 2 views
1

У меня есть ошибка, что idk, как ее исправить. Ошибка: «Определение конфликтует с предыдущим значением». Я скопировал приведенный ниже код и выделил часть, помеченную. Спасибо заранее.Смущает протокол UITableViewDataSource. Конфликты с предыдущими

import UIKit 
import Parse 
class ScienceTableViewController: UITableViewController, UITableViewDataSource { 
    var dataRecords = [Data]() 

    override func viewDidLoad() { 
     super.viewDidLoad() 

    override func viewWillAppear(animated: Bool) { 
     super.viewWillAppear(animated) 

     dataRecords = [Data]() 

     let query = PFQuery(className: "data") 

     query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]?, error: NSError?) -> Void in 

      if error == nil { 

       for object in objects! { 

        let data = Data(objectID: object.valueForKey("objectId")! as! String, title: object.valueForKey("title")! as! String, date: object.valueForKey("date")! as! String, information: object.valueForKey("information")! as! String) 


        self.dataRecords.append(data) 
        self.tableView.reloadData() 

       } 

      } else {    
       print(error) 
      } 
     } 
    } 

    override func didReceiveMemoryWarning() { 

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

    // MARK: - Table view data source 

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
     return dataRecords.count > 0 ? 1 : 0 

    } 

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


    **override func tableView(tableView: UITableView**, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) 

      // Configure the cell... 

     let title = dataRecords[indexPath.row].title 
     let date = dataRecords[indexPath.row].date 
     let information = dataRecords[indexPath.row].information 

     cell.textLabel?.text = title 
     cell.detailTextLabel?.text = date 


     return cell 
     } 

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 
     let controller: ViewController = segue.destinationViewController as! ViewController 

     if segue.identifier == "newData" { 

      controller.objectID = "" 

     } else if segue.identifier == "showData" { 

      let indexPath: NSIndexPath = self.tableView.indexPathForSelectedRow! 
      controller.objectID = dataRecords[indexPath.row].objectID 


     } 

    } 


    }} 

Я также получаю проблемы с Xcode, где он утверждает, «Xcode столкнулись с проблемой. Функциональность Source редактор ограничен. Попытка восстановить» и редактор не распознает код для кратких моментов.

+0

что это ** перед тем cellforrowindex? –

+0

@ Mr.T просто подчеркнуть это. :) –

ответ

0

Я считаю, что ваша проблема связана с линией объявления класса, которая имеет UITableViewDataSource в качестве протокола. UiTableViewController уже является источником данных, поэтому он является избыточным и должен быть удален.

+0

Я удалил UITableViewDataSource в качестве протокола, и проблема все еще сохраняется. Кроме того, я пытался сменить AnyObjects на PFObjects и до сих пор не повезло. –

+0

У вас есть расширение на sciencetableviewcontroller? Вы можете дублировать его в другом файле. – Jeremiah

Смежные вопросы