Reputation: 1666
I want to associate a block with some identifier, and store it in a dictionary for later retrieval.
Am I doing this wrong? Basically I'm worried that I might be passing in a block that is declared on the stack via setAction:forProduct, and the reference will later be invalidated. Is ARC smart enough to catch this?
typedef void (^ProductPurchased)();
-(void) setAction:(ProductPurchased)action forProduct:(NSString*)identifier;
@property (strong, nonatomic) NSMutableDictionary *actions;
-(void) setAction:(ProductPurchased) action forProduct:(NSString*)identifier
{
[self.actions setObject:action forKey:identifier];
}
Upvotes: 0
Views: 179