1

I have a table view which I am populating after fetching data from my API. But now I am getting an error message "Editor placeholder in source file". I simply just can't get where am I doing the mistake. Please give some idea?

here is my code -

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


    }


}

I have also attached a screenshot of my project to make things more clear

enter image description here

G.Abhisek
  • 1,034
  • 11
  • 44

2 Answers2

0

If your'e using the xcode version 7.x try to remove the as! CustomTableViewCell downcast. Just use let cell = tableView.dequeueReusableCellWithIdentifier("cellreuse", forIndexPath: indexpath) is enough.

Mohanmoorthy
  • 129
  • 5
0

you are not using indexPath so just remove that.

Use this snippet:

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

Clean and run the project and enjoy!.

Fabrice Kabongo
  • 671
  • 10
  • 23