Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Problems when using objc_util()
-
@cvp, thanks. That sounds likely, due to the ObjCInstance wrapper not always being up to speed with the actual ObjC instance.
-
@mikael Sincerely, I don't know but why to define a "completion handler" (which we could think it is called after completion) and also a "progress tracker"?
-
@cvp
This is Apple's UI design. The completion handler is asynchronous and runs immediately.
"ItemProvider. Loadobjectofclass_completionhandler_()" returns a progress, which can cancel operations or obtain progress data. During this period, developers can design a set of suitable UI animation to reduce the waiting experience of users, or cancel loading. -
@rozaimech Yes, I know, I had read it also but, I think (maybe, or better, sure, I'm wrong) that a "completion handler" is called after completion...
-
@cvp
Usually the second run has an error,maybe it's after first completion...... -
@rozaimech, recommend trying
objc_util.retain_global
on the delegate. Classic fix for ”second run” issues. -
@rozaimech, I forgot that we need to retain the reference to the block. This seems reliable, and no progress needed:
def handler(_cmd, _object, _error): obj = ObjCInstance(_object) print(obj) handler_block = ObjCBlock( handler, restype=None, argtypes=[c_void_p, c_void_p, c_void_p]) retain_global(handler_block)
-
-
@mikael said:
I forgot that we need to retain the reference to the block.
I also knew it from a previous similar problem but I already forgot it, as usual 😢
-
@rozaimech We have also to thank @JonB for his help about threads.
I didn't know this calling wayon_main_thread(original_func)(args)
-
@cvp, yes. It applies to all descriptors, by definition.
Due to a bug, same way of calling using
on_main_thread
is currently needed forset_idle_timer_disabled
not to crash.