我在我的didSelectRowAtIndexPath
方法中遇到異常,我不太清楚爲什麼。我向用戶展示了他們可以選擇的可能性列表,UITableView
根據存儲在覈心數據中的值進行填充。當前選擇的項目有一個Checkmark
指標。我的方法是如下:在發佈模式下的應用程序異常,而不是在調試模式下
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
let value = self.fetchedResultsController.objectAtIndexPath(indexPath) as CoreDataObject
currentSelected = value.id as Int
self.tableView.reloadData()
}
在開發模式是好的,但在生產和testflight崩潰的這種方法。崩潰日誌如下:
Crashed Thread 0 :
0 CoreFoundation 0x25f41a7d _CFRetain + 165
1 UIKit 0x29619d67 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 919
2 UIKit 0x296cb9df -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 195
3 UIKit 0x2957da25 _applyBlockToCFArrayCopiedToStack + 309
4 UIKit 0x294f982b _afterCACommitHandler + 459
5 CoreFoundation 0x26007d95 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21
6 CoreFoundation 0x26005453 __CFRunLoopDoObservers + 279
7 CoreFoundation 0x2600585b __CFRunLoopRun + 915
8 CoreFoundation 0x25f533c1 CFRunLoopRunSpecific + 477
9 CoreFoundation 0x25f531d3 CFRunLoopRunInMode + 107
10 GraphicsServices 0x2d3510a9 GSEventRunModal + 137
11 UIKit 0x29562fa1 UIApplicationMain + 1441
有什麼我在這裏失蹤?爲什麼這種方法會崩潰?我只是存儲當前選擇的ID,然後重新加載數據,以便它可以在重新加載後顯示覆選標記。有什麼我在這裏失蹤?它應該很簡單,只需獲取新的ID然後重新加載數據即可。
我使用的CoreDataObject
是從Objective-C
和id
字段是NSNumber
。
我嘗試過其他的解決方案如下:
Crash when calling selectRowAtIndexPath:animated:scrollPosition:
iphone app crash at -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
iOS - didSelectRowAtIndexPath causes crash in app