ios - Error displaying a prototype cell and its content -
i'm doing rob's udemy ios8 swift course , far good.
i use tab bar controller separate tabs: profile, ask, browse etc...
in 'ask' tab, input text , uploaded parse , want text displayed in 'browse' tab. browse tab table view prototype cell, added labels there display username , text.
my problem doesn't display text nor username parse. here code:
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] { 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 } }
error message:
nil
i can see loading data (from parse) gives me error message. doesn't crash tho.
thanks!
Comments
Post a Comment