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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -