【发布时间】:2016-04-17 00:03:02
【问题描述】:
我在第 389 行遇到 EXC_BREAKPOINT 崩溃
386 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
387 let cell = tableView.dequeueReusableCellWithIdentifier("StationsCell", forIndexPath: indexPath)
388 cell.textLabel?.text = self.suggestionStations?[indexPath.row]
389 return cell
390 }
这是来自 Crashlytics 的崩溃报告,发生在 2% 的用户中:
Thread : Crashed: com.apple.main-thread
0 Trenìt! 0x10004a2e4 specialized MasterViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (MasterViewController.swift:389)
1 Trenìt! 0x100046488 @objc MasterViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (MasterViewController.swift)
2 UIKit 0x18c6b239c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 544
3 UIKit 0x18c6a6fc4 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2360
4 UIKit 0x18c49cc60 -[UITableView layoutSubviews] + 172
5 UIKit 0x18c3b9874 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 572
6 QuartzCore 0x18bd11d58 -[CALayer layoutSublayers] + 168
7 QuartzCore 0x18bd0c944 CA::Layer::layout_if_needed(CA::Transaction*) + 320
知道为什么会这样吗?
【问题讨论】:
-
单元格可能是
nil。你检查了吗? -
崩溃日志中是否有人类可读的错误消息?
-
@rmaddy 这是我能得到的唯一崩溃日志,它来自 Crashlytics
-
@ozgur,单元格是否有可能有时为零,有时不是?考虑到返回值
UITableViewCell不是可选的,如果单元格为nil,我该怎么办? -
这段代码有没有可能总是崩溃,但只有 2% 的用户使用它?比如它是否提供了一些很少需要的功能?
标签: ios swift uitableview