我在解析数据和UITableView设置时遇到问题。每当我运行该应用程序时,无论是在模拟器上还是在手机上,该应用程序都会停止运行,并且控制台显示的唯一内容是(lldb)
。检查调试器时,仅突出显示以下两行代码。
findTimelineData.findObjectsInBackgroundWithBlock{
和
self.timelineData = array as NSMutableArray
两者都有错误:
Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT,subcode=0x0)
并且我不太清楚那是什么意思...这是我的代码片段:
override func viewDidAppear(animated: Bool)
{
self.loadData()
}
func loadData()
{
timelineData.removeAllObjects()
var findTimelineData : PFQuery = PFUser.query()
findTimelineData.findObjectsInBackgroundWithBlock{
(objects: [AnyObject]!, error: NSError!)-> Void in
if error == nil
{
println("No error")
if let object = objects as? [PFObject!]
{
for object in objects
{
self.timelineData.addObject(object)
}
}
let array : NSArray = self.timelineData.reverseObjectEnumerator().allObjects
self.timelineData = array as NSMutableArray
self.tableView.reloadData()
}
}
}
这些将是我要加载的单元格,但是代码永远都无法实现……
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
println("loading cell")
let postCell : LocationTableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as LocationTableViewCell
let post : PFObject = self.timelineData.objectAtIndex(indexPath.row) as PFObject
postCell.imageView.image = post.objectForKey("currentLocation") as? UIImage
postCell.userInfo.text = post.objectForKey("FirstLastName") as? String
// Configure the cell...
return postCell
}
完整代码:http://pastebin.com/MN7qcFhq
最佳答案
这为我工作:
在您的代码中只是替换
self.timelineData = array as NSMutableArray
至
self.timelineData = NSMutableArray(array: array)
关于ios - UITableView和解析数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26818752/