1
我正在使用Master-Detail模板,并且tableView.insertRowsAtIndexPaths需要大约20-25秒的时间才能将单行添加到主视图中(在添加完代码后)。我是iOS开发新手,所以我想知道我应该如何诊断这种性能问题。Swift:我该如何调试这种糟糕的性能?
当我通过代码,我可以看到,一切似乎都很快完成,但应用程序进去__NSCFLocalSessionTask _task_onqueue_didFinish一圈又一圈)_block_invoke
我意识到这是没有太多去。我希望有人能指出我正确的方向。
let service = Service()
service.getJson(url!) { (json, error) ->() in
if error != nil && json != nil {
print(error!)
//return error!
} else {
jsonResult = json
if let nameResult:AnyObject = jsonResult["name"] {
// Insert the new Board in the Master list
self.objects.insert(nameResult, atIndex: 0)
self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
self.activityIndicatorView.stopAnimating()
你可以请张贴一些代码吗? – Siriss
完成,但不知道它会有多大的帮助。我添加了跟踪,每段代码都很快完成。我在挠头。 – beachCode
难道这是“UI更新必须在主线程上完成”的无数次重复吗? –