i have simple asynchronous operation
@interface idbwebpvalidationoperation() @property bool executing; @property bool finished; @end @implementation idbwebpvalidationoperation @synthesize executing; @synthesize finished; - (instancetype)init { self = [super init]; if (self) { self.completionblock = ^{ nsdlog(@"webp validation has finished"); }; } return self; } - (void)main { idbassert0(self.bestcapture.webpcandidate); self.finished = no; if(self.postprocessingvalidator) { self.executing = yes; // starts async operation, see callback below self.postprocessingvalidator(self.bestcapture.webpcandidate); }else{ idbassert0(0); // self.bestcapture.jpegnsdata = self.bestcapture.webpcandidate; idbassert0(self.bestcapture.jpegnsdata); self.executing = no; self.finished = yes; } } - (void)scanningviewcontroller: (uiviewcontroller<ppscanningviewcontroller>*)scanningviewcontroller didoutputresults:(nsarray*)results { if([results count]>0) { self.bestcapture.jpegnsdata = self.bestcapture.webpcandidate; idbassert0(self.bestcapture.jpegnsdata); }else{ idbassert0(self.microblinkfailurehandler); self.microblinkfailurehandler(); } idbassert0(!self.finished); self.executing = no; self.finished = yes; } -(bool)isasynchronous { return yes; //default no overriding return yes; }
here have synthesized 2 atomic properties executing & finished avoid lots of (in opinion dumb & extraneous) code swift force kvo , synthesided atomic properties me out of box (i think).
the issue completionblock called before scanningviewcontroller: callback invoked. why?????
this on ios 9.3.x in case matters
Comments
Post a Comment