Checking the execution of blocks and queues in NSDictionary

I have an array of dictionaries that stores blocks and queues. After some method, I need to 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, my question is: how to verify run time, that dict[@"block"]and dict[@"queue"]- this is the type that I expected? I have typedef void(^handler)();, and I have to be sure that dict[@"block"]is a type handler. As I know, blocks and queues are actually objective-c objects, but do not comply with the protocol <NSObject>. So, do it anyway?

Thanks in advance!

+4
source share
1 answer

block/queue . .

//Block class
@interface myBlock : NSObject

@property (assign) dispatch_block_t block;

@end

//Queue class
@interface myQueue : NSObject

@property (assign) dispatch_queue_t block;

@end
0

Source: https://habr.com/ru/post/1533161/


All Articles