ios - how to do cancel requests in GCD without operation queue -
i'm implementing ios app make requests using rest service. , want cancel previous rest calls when make new call. can in global queue in gcd without operation queue? thanks
gcd not provide api cancel blocks. have implement cancellation yourself.
the easiest way set global flag 'canceled' , check inside of blocks. if flag set, return block. after blocks have finished can reset flag , enqueue new block.
even though sounds simple, requires nontrivial code. easier use nsoperationqueue instead of reimplementing features on top of plain gcd.
Comments
Post a Comment