我从我的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
}
}
如果傻冒使用Xcode 7.x版我还附上我的项目的截屏,以使事情更加清楚
也许这两个链接会帮助你? 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
我已经读过,但这里的东西是不同的。 –
你最初是否从其他地方粘贴过这段代码? – Moonwalkr