即使对象存在,我也得到EXC_BAD_ACCESS(code = 1,address = 0x30)错误的访问权限-swift 4 [英] I am getting EXC_BAD_ACCESS (code=1, address=0x30) Bad Access even when object exists - swift 4
问题描述
我初始化变量----> idHERE:
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
但是当我尝试使用第二张照片时 idHERE.value-我无法访问EXC_BAD_ACCESS(代码= 1,地址= 0x30)
But on the second print when I try to use idHERE.value - I get a bad access EXC_BAD_ACCESS (code=1, address=0x30)
这怎么可能?
调试器也会很好地显示所有值.
The debugger shows all the values fine as well.
我尝试在没有帮助的情况下以发布模式运行代码.
I have tried running the code in release mode with no help.
请帮助!!
Xcode 9 swift4
Xcode 9 swift4
此外,我将其从let更改为var,以查看是否有所不同.
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.
此外,不调用deinit.我有一个用于deinit的打印语句,它没有被调用.
Also, deinit is NOT called. I have a print statement for deinit and it is not called.
谢谢!
推荐答案
到目前为止,我唯一的解决方法是将发布和调试的优化级别更改为-02.现在它工作"了.迅捷的人需要看看这个!!
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!!
这篇关于即使对象存在,我也得到EXC_BAD_ACCESS(code = 1,address = 0x30)错误的访问权限-swift 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!