I am currently using GCD. However, I've heard that NSOperation
is actually a higher level program. It's far more complex though.
In GCD, do something at background is simply use this helper function I created:
+(void)doForeGround:(void (^)())block
{
dispatch_async(dispatch_get_main_queue(), ^{
block();
});
}
+(void)doBackground:(void (^)())block
{
//DISPATCH_QUEUE_PRIORITY_HIGH
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0), ^{
//dispatch_async(dispatch_get_global_queue(-2,0), ^{
block();
});
}
-(void)doBackGround:(void (^)())block onComletion:(void (^)())onCompletion
{
[BGHPTools doBackground:^{
block();
[BGHPTools doForeGround:^{
onCompletion();
}];
}];
}
Will doing it with NSOperation
be simpler?
Am I missing something? How would I do the same thing at NSoperation?