0
我希望有人能夠幫助,因爲我正在嘗試調試,但我正在圍繞着一圈。 我在Parse.com中有一個表格,可以成功查詢和檢索數據。 我用println做了一個測試,輸出中顯示正確的字符串值。 我試圖做的是把這些值放到UITableView中,但是這讓我失望了一些非常令人沮喪的路徑(我仍然試圖儘可能地學習這些,有時候一些概念很難理解)。在SWIFT中未使用Parse.com結果填充UiTableView結果
我最後一次嘗試(見下面的代碼)我認爲通過將值寫入結構我可以像以前那樣使用它,因爲我可以看到我需要填充的值。我不認爲這是正確的方式,但我認爲它應該工作。
我的代碼,當我把一個斷點沒有得到,甚至定義實現代碼如下:( 我知道我失去了一些東西,但也許只需要一個新鮮的一雙眼睛幫我看看,我錯過了什麼。 任何幫助將不勝感激:
@IBOutlet weak var navlabel: UILabel!
var TopicPassed:String!
var storedsentences=[getsentences]()
@IBOutlet weak var sentencetableview: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
navlabel.text = TopicPassed
var query = PFQuery(className:"TalkToMeSentences")
query.whereKey("Topic", equalTo:TopicPassed)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
// query successful - display number of rows found
println("Successfully retrieved \(objects.count) sentences")
// print sentences found
for object in objects {
let retrievedsentences = object["Sentence"] as NSString
self.storedsentences = [getsentences(parsesentence: "\(retrievedsentences)")]
println("\(retrievedsentences) ")
}
self.sentencetableview.reloadData()
} else {
// Log details of the failure
println("Error: \(error) \(error.userInfo!)")
}
}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return storedsentences.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
var sentence : getsentences
// Configure the cell...
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
cell.textLabel!.lineBreakMode = NSLineBreakMode.ByWordWrapping
sentence = storedsentences[indexPath.row]
cell.textLabel!.text = sentence.parsesentence
cell.textLabel?.numberOfLines = 0
return cell
}
你是什麼意思「我的代碼,當我把斷點,甚至沒有得到甚至定義tableview」...是'cellForRow:'沒有被調用?檢查以確保您的數據源/代理已定義 – 2015-03-02 07:51:49
是的,它沒有到達那裏,我添加了TableView代碼。 – 2015-03-02 08:15:19
它是在numberOfRowsInSection方法嗎? – sanjana 2015-03-02 10:33:26