【发布时间】:2015-08-28 00:08:10
【问题描述】:
试图在 uitableviewcell 内的 textview 中显示从 parse.com 提取的数组。其他所有内容都在显示,但我似乎无法在文本视图中显示数组。这是我的代码。我收到致命错误:myCell2.feedbacktextview.text = feedback![indexPath.row]
的数组索引超出范围var feedback: [String]?
override func viewDidLoad() {
super.viewDidLoad()
var query = PFQuery(className: "Post")
query.findObjectsInBackgroundWithBlock({ (objects, error) -> Void in
if error == nil {
if let objects = objects {
if object.objectForKey("Comments") != nil {
self.feedback = object.objectForKey("Comments") as! [String]
}
self.tableView.reloadData()
}}}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell2 = tableView.dequeueReusableCellWithIdentifier("feedcell1", forIndexPath: indexPath) as! YourAdviseControllerCell
myCell2.feedbacktextview.text = feedback![indexPath.row]
return myCell2
}
编辑: self.imageFiles.append(object["imageFile1"] as!PFFile)
self.imageFiles2.append(object["imageFile2"] as! PFFile)
self.usernames.append(object["message"] as! String)
self.usernames2.append(object["declaration"] as! String)
self.usernames3.append(object["whichbutton"] as! String)
【问题讨论】:
-
嗨,我有一个问题,因为我陷入了与此类似的问题。您正试图让用户对帖子发表评论,对吗?如果是这样,当您按下回复按钮或其他东西时,即使它没有显示在应用程序上,它是否也在数据库中更新?
-
在我的应用程序中没有它的消息,在数据库中发送消息更新,但是当我查看他的帖子时,我无法让它显示给消息的接收者。
-
哦,我明白了,我猜编码部分应该与您从数据库中获取数据的方式相似,只是显示方式不同。但是,是的,我也遇到了麻烦。
标签: ios swift uitableview parse-platform