问题
Similar to This SO Post and This SO Post
I initialize a variable ----> idHERE:
static func createPractitionerRole(fromRoleDict roleDict:[String: AnyObject])->PractitionerRole?{
guard let (nameL, idL) = getRoleNameId(fromRoleDict:roleDict) else {
return nil
}
let roleTypeL = ProTouchRoleType.determineRoleTypeFromProTouchId(idL)
var idHERE = Identifier(withValue: idL, systemParam:Constants.CodeSystem.ProTouch.coding_system_proTouchURL)
print("idHERE \(String(describing: idHERE))")
print("idHERE.value \(String(describing: idHERE.value))")
return PractitionerRoleUtils.createPractitionerRole(withId:idHERE, name: nameL, roleType: roleTypeL)
}
On the first print it prints out the object:
idHERE Identifier Object- system:Optional(http://www.anyApp.com/any) value:Optional("319/43") use:usual period:nil
But on the second print when I try to use idHERE.value - I get a bad access EXC_BAD_ACCESS (code=1, address=0x30)
How is this possible?
The debugger shows all the values fine as well.
I have tried running the code in release mode with no help.
Please help!!
Xcode 9 swift4
Also, I changed this from a let to a var to see if that made a difference.
This after some complicated code, but I'm not sure why that would make a difference. Why, if you initialize something, can't you access the values immediately after.
Also, deinit is NOT called. I have a print statement for deinit and it is not called.
Thanks!
回答1:
My only work around as of now is changing the optimization level to -02 for both release and debug. Now it "works". Someone from swift needs to look at this!!
Links to Look at Later 1
Also had bad access and changed optimization level
来源:https://stackoverflow.com/questions/48795609/i-am-getting-exc-bad-access-code-1-address-0x30-bad-access-even-when-object-e