objective c - Runtime checking of Blocks and Queues in NSDictionary -
this question has answer here:
- checking objective-c block type? 5 answers
i have array of dictionaries, stores blocks , queues. after method need execute it.
for (nsdictionary * dict in self.arrayofblocksandqueues) { if (!dict[@"block"] || !dict[@"queue"]) { continue; } dispatch_block_t block = dict[@"block"]; dispatch_async(dict[@"queue"], ^{ block(); }); }
so question is, how can check in runtime, dict[@"block"]
, dict[@"queue"]
type i’m expected? have typedef void(^handler)();
, need sure dict[@"block”]
type of handler
. know, blocks , queues in fact objective-c objects, don’t conforms <nsobject>
protocol. so, there anyway it?
thanks in advance!
you can create class block/queue property easy manipulation. try setting block , queue properies class , add objects in dictionary.
//block class @interface myblock : nsobject @property (assign) dispatch_block_t block; @end //queue class @interface myqueue : nsobject @property (assign) dispatch_queue_t block; @end
Comments
Post a Comment