i have following function:
func delete() { if (deletecounter == 0) { print("deletion start") deletecounter = 1 // execute async delete task dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_high, 0), { if (self.textdocumentproxy.isproxy()) { _ in 1..<50 { (self.textdocumentproxy uikeyinput).deletebackward() } } print("deletion end") self.deletecounter = 0 }) } else { print("denying deletion") } }
where deletecounter
integer set 0 default.
the code supposed function when delete key on custom keyboard app extension pressed, not call delete loop if still looping, preventing many method calls.
the code seems working fine, if hit delete button rapidly (thus calling function repeatedly) large period of time following error:
thread 3: exc_bad_access(code = 1,address=0x10)
on line:
(self.textdocumentproxy uikeyinput).deletebackward()
i not ever modify self.textdocumentproxy
object because default object ios provides keyboard extensions can access.
after reading on exc_bad_access
error figured out because self.textdocumentproxy
object being released memory @ point.
how prevent self.textdocumentproxy
being released, or how make sure can non-released copy of object?
update:
i enabled zombie objects , following error message:
[_uiinputviewcontrolleroutput setkeyboardoutputs:]: message sent deallocated instance 0x146435b10
this seems confirm suspicion self.textdocumentproxy
being de-allocated.
Comments
Post a Comment