我遇到了崩溃EXC_Breakpoint
这会告诉我有一个nil
变量被解包?
它指向的代码行是let obHeight 的定义:
if let qs = Helper_Question.getSection(sid: self.sections[0].sid) {
let obEnabled = Helper_Type.getId(id: tid)?.enableObservation == 1
for q in qs {
let ans = Helper_Answer.getQuestion(aid: selectedAid!, qid: q.Id)
var baseHeight : CGFloat = 300
switch(q.qtype){
case Constants.DEFAULT:
let obHeight : CGFloat = (obEnabled || ans?.comment != "" || (ans?.answer == "1" && q.hasChildren == 0) || (ans?.answer == "2" && q.hasChildren == 0)) && ans?._na == 0 ? 40 : 0
....
}
}
}
我使用?
而非强行展开,所以我不认为这是问题所在?此崩溃报告今天发布,但我无法在任何设备上重现它。除nil
变量之外的其他原因会导致EXC_Breakpoint
崩溃吗?在表视图单元格中单击按钮的操作调用此代码,并在呈现splitviewcontroller之前使用委托调用此代码进行一些计算。 selectedAid来自按钮的可访问性标识符,我总是在行的单元格中设置。它不是零
崩溃日志:
Crashed: com.apple.main-thread
0 AppName 0x100664b30 specialized AuditVC.editBtnTapped(cell : PendingAuditTVC) -> () (AuditVC.swift:294)
1 AppName 0x10065fa68 AuditVCAppNamePendingAuditCellDelegate (AuditVC.swift)
2 AppName 0x100717468 PendingAuditTVC.editTapped(Any) -> () (PendingAuditTVC.swift:41)
3 AppName 0x100717648 @objc PendingAuditTVC.editTapped(Any) -> () + 4302730824
4 UIKit 0x1907c6010 -[UIApplication sendAction:to:from:forEvent:] + 96
5 UIKit 0x1907c5f90 -[UIControl sendAction:to:forEvent:] + 80
6 UIKit 0x1907b0504 -[UIControl _sendActionsForEvents:withEvent:] + 440
7 UIKit 0x1907c5874 -[UIControl touchesEnded:withEvent:] + 576
8 UIKit 0x190d5a550 _UIGestureEnvironmentSortAndSendDelayedTouches + 4280
9 UIKit 0x190d5689c _UIGestureEnvironmentUpdate + 1128
10 UIKit 0x190d563e0 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 404
11 UIKit 0x190d5568c -[UIGestureEnvironment _updateGesturesForEvent:window:] + 268
12 UIKit 0x1907c070c -[UIWindow sendEvent:] + 3164
13 UIKit 0x19079133c -[UIApplication sendEvent:] + 340
14 UIKit 0x190f8b014 __dispatchPreprocessedEventFromEventQueue + 2400
15 UIKit 0x190f85770 __handleEventQueue + 4268
16 UIKit 0x190f85b9c __handleHIDEventFetcherDrain + 148
17 CoreFoundation 0x18a61542c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
18 CoreFoundation 0x18a614d9c __CFRunLoopDoSources0 + 540
19 CoreFoundation 0x18a6129a8 __CFRunLoopRun + 744
20 CoreFoundation 0x18a542da4 CFRunLoopRunSpecific + 424
21 GraphicsServices 0x18bfac074 GSEventRunModal + 100
22 UIKit 0x1907f6058 UIApplicationMain + 208
23 AppName 0x100044590 main (AppDelegate.swift:23)
24 libdyld.dylib 0x18955159c start + 4
更新
open class Question
{
open var Id : Int = 0
open var sectionid : Int = 0
open var question : String = ""
open var hasChildren : Int = 0
open var qtype : Int = 0
open var defaultValue : String = ""
}
public class UP_IA_Answer_m : EVObject {
public var localId : String = ""
public var aid : String = ""
public var sid : Int = 0
public var qid : Int = 0
public var answer : String = ""
public var comment : String = ""
public var hasChildren : Int = 0
public var _na : Int = 0
}
答案 0 :(得分:-1)
用" x"替换单行的值和变量名称。使错误更容易发现:
(x || x?.x!= x ||(x?.x == x&& x == x)||(x?.x == x&& x == x))&& x?.x == x? x:x
我认为错误发生的地方非常清楚。