我正在做Rob的UDEMY iOS8 Swift课程,到目前为止一直很好。
我使用标签栏控制器来分隔标签:个人资料,提问,浏览等...
在“提问”标签中,我输入了一个文本并成功上传到Parse,我希望该文本显示在“浏览”选项卡中。 “浏览”选项卡是一个带有原型单元格的表视图,我在那里添加了标签以显示用户名和文本。
我的问题是它不显示文本,也不显示Parse的用户名。这是代码:
import UIKit
import Parse
class browseViewController: UITableViewController{
var postedQuestion = [String]()
var usernames = [String]()
override func viewDidLoad() {
super.viewDidLoad()
var query = PFQuery(className:"Post")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error != nil {
if let objects = objects as? [PFObject] {
for object in objects {
self.postedQuestion.append(object["postedQuestion"] as! String)
self.usernames.append(object["username"] as! String)
self.tableView.reloadData()
}
}
} else {
println(error)
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return usernames.count
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 227
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var myCell:cell = self.tableView.dequeueReusableCellWithIdentifier("myCell") as! cell
myCell.postedQuestion.text = postedQuestion[indexPath.row]
myCell.username.text = usernames[indexPath.row]
myCell.sizeToFit()
return myCell
}
}
错误讯息:
零
我可以看到它正在加载数据(来自Parse)但是它只是给了我那个错误信息。它不会崩溃。
谢谢!