Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在SWIFT的表视图中填充自定义单元格时出错_Swift_Uitableview_Uiscrollview_Ios9 - Fatal编程技术网

在SWIFT的表视图中填充自定义单元格时出错

在SWIFT的表视图中填充自定义单元格时出错,swift,uitableview,uiscrollview,ios9,Swift,Uitableview,Uiscrollview,Ios9,我有一个表视图,从API中获取数据后,我将填充该表视图。但现在我收到一条错误消息“源文件中的编辑器占位符”。我只是不知道我在哪里犯了错误。请给出一些想法 这是我的密码- import UIKit class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { @IBOutlet weak var tblvww: UITableView! var dict = [:]

我有一个表视图,从API中获取数据后,我将填充该表视图。但现在我收到一条错误消息“源文件中的编辑器占位符”。我只是不知道我在哪里犯了错误。请给出一些想法

这是我的密码-

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


    }


}
我还附上了我的项目截图,使事情更清楚


如果您使用的是xcode 7.x版,请尝试将
删除为!CustomTableViewCell
downcast。只需使用
let cell=tableView.dequeueReusableCellWithIdentifier(“cellreuse”,forIndexPath:indexpath)
就足够了。

如果您使用的是xcode版本7.x,请尝试将
删除为!CustomTableViewCell
downcast。只需使用
let cell=tableView.dequeueReusableCellWithIdentifier(“cellreuse”,forIndexPath:indexpath)
就足够了。

您没有使用
indexpath
,所以只需删除它即可

使用以下代码段:

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

清洁并运行项目,享受

您没有使用
indepath
,所以只需删除它即可

使用以下代码段:

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

清洁并运行项目,享受

也许这两个链接对你有帮助?我已经读过了,但这里的情况有所不同。你最初是从其他地方粘贴这段代码的吗?也许这两个链接会对你有所帮助?我已经读过了,但这里的情况有所不同。您最初是从其他地方粘贴此代码的吗?好的,那么我的编译器如何识别“cell”是我的customTableView子类的一种类型?好的,那么我的编译器如何识别“cell”是我的customTableView子类的一种类型?