ios - Reskit - callback on the same thread instead of UI thread -
I am displaying getObjectsAtPath in a background thread. However, success / failure blocks are called on UI threads.
Is there any way to force the resetkit to call success and failure blocks on the same thread instead of the UI thread?
"itemprop =" text ">
Restkit does not provide this functionality, but you can do this archive.
RKObjectRequestOperation
class has two properties successClallQQueue
& amp; failureClallQQueue
, which allows you to set the call back queue RKObjectManager
Overwrite the class and return RKObjectRequestOperation
so you can set the callback queue < / P>
- (RKObjectRequestOperation *) getObjectsAtPath :. (NSString *) path parameters: (NSDictionary *) success parameters: (void (^) (RKObjectRequestOperation * operation, RKMappingResult * mappingResult)) success or failure: (void (^) (RKObjectRequestOperation * operation, NSError * error)) failure {NSParameterAssert (Path); RKObjectRequestOperation * operation = [self-appropriateObjectRequestOperationWithObject: zero method: RKRequestMethodGET path: path parameter: parameter]; [OperationSetSlamBlockWith: Success: Success Failure: Failure]; [Auto-envoobjecture operation: operation]; Return Operation; }
Then you can set the callback queue detected by bellow:
RKObjectManager * objectManager = [RKObjectManager sharedManager]; RKObjectRequestOperation * Operation = [objectManager getObjectsAtPath: path parameters: Parameters success: ^ (RKObjectRequestOperation * operation, RKMappingResult * mappingResult) {} Failure: ^ (RKObjectRequestOperation * operation, NSError * error) {}]; Operation.successClallQQueue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); Operation.philarcodeback Queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
Comments
Post a Comment