2015-12-09 2 views
1

У меня есть табличное представление, которое я заполняю после получения данных из моего API. Но теперь я получаю сообщение об ошибке «Заполнитель редактора в исходном файле». Я просто не могу получить, где я делаю ошибку. Пожалуйста, дайте представление?Ошибка при заполнении пользовательской ячейки в представлении таблицы в SWIFT

вот мой код -

import UIKit 

class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource 
{ 

    @IBOutlet weak var tblvww: UITableView! 
    var dict = [:] 

    override func viewDidLoad() 
    { 
     super.viewDidLoad() 



    func fetchdata() 
    { 
     let url = NSURL(string: "***") 
     let request = NSURLRequest(URL: url!) 
     let urlsession = NSURLSession.sharedSession() 
     let jsonquery = urlsession.dataTaskWithRequest(request) { (data, response, error) -> Void in 

      if let retrieveddata = data 
      { 
       self.dict = (try! NSJSONSerialization.JSONObjectWithData(retrieveddata, options: NSJSONReadingOptions.MutableContainers)) as! NSDictionary 
      } 


     } 
     jsonquery.resume() 

    } 


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

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 
    { 

     let cell = tableView.dequeueReusableCellWithIdentifier("cellreuse", forIndexPath: indexpath) as! CustomTableViewCell `[![//here I get the error "Editor placeholder in source file"][1]][1]` 

     let vendorname = dict.valueForKey("vendor")?.objectAtIndex(0).valueForKey("name") 
     cell.vndrlbl.text = vendorname as? String 
     return cell 


    } 


} 

Я также прилагается скриншот моего проекта, чтобы сделать вещи более ясно

enter image description here

+0

Возможно, эти две ссылки помогут вам? http://stackoverflow.com/questions/31968278/xcode-7-err-editor-placeholder-in-source-code http://stackoverflow.com/questions/33088305/xcode-7-error-editor-placeholder-in -source-file – Moonwalkr

+0

Я прочитал это, но здесь дело в другом. –

+0

Вы изначально вставляли этот код из другого места? – Moonwalkr

ответ

0

Если your'e с помощью Xcode версии 7.x попробуйте удалить as! CustomTableViewCell downcast. Просто используйте let cell = tableView.dequeueReusableCellWithIdentifier("cellreuse", forIndexPath: indexpath).

+0

Итак, как мой компилятор узнает, что «cell» - это тип моего подкласса customTableView? –

0

Вы не используете indexPath, поэтому просто удалите это.

Используйте этот фрагмент кода:

let cell: TestTableViewCell = tableView.dequeueReusableCell(withIdentifier: "CellMate") as! TestTableViewCell 

Чистый и запустить проект и наслаждайтесь !.

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