I am somewhat new to blocks and need some help. I want to store a block in an NSDictionary and execute said block when it is accessed based off its key. Here is what I have so far as an example.
NSDictionary *blocks = [NSDictionary dictionaryWithObjectsAndKeys:
^{NSLog(@"Log Block 1");}, @"Block1",
^{NSLog(@"Log Block 2");}, @"Block2",
nil];
I then enumerate through the dictionary by using keyEnumerator. I know the block is being stored properly because I call NSLog(@"%@", [blocks objectForKey:key]); during the enumeration and get <__NSGlobalBlock__: 0x100003750>. So I know I can access it but how can I execute it at this point?
Try this: