I'm getting a crash EXC_Breakpoint
which would indicate to me that there is a nil
variable being unwrapped?
The line of code it is pointing to is the definition of 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
....
}
}
}
I'm using the ?
instead of forcefully unwrapping so I don't think this is the issue? This crash report came into today but I cannot reproduce it on any device. What other reason apart from a nil
variable would cause a EXC_Breakpoint
crash? This code is called on action of a button click in a table view cell and uses a delegate to call this code to do some calculations before presenting a splitviewcontroller. selectedAid comes from the button's accessibility identifier which i am setting in the cell for row, always. it is not nil
crash log:
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
UPDATE
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
}
? true : false
is unnecessary, leave it out. – Uraniaq
is not nil? – UraniaQuestion
andAnswer
, which I assume is the model names... – Chesterfieldianlet obHeight ...
? – Chesterfieldian