Prevent ARC from not currently being used, but soon?

I ran into this problem a couple of times and want to know the right approach.

As an example, suppose I am writing an application for the iPhone and I need a custom alert presentation class that uses blocks.

So, I write a class, and then in my code I go:

MyAlertView *alert = [MyAlertView alertWithBlahBlahBlah...];
[alert addButton:@"button" withBlock:^{ ... }];
[alert show];

Somewhere in the alert view class we have

- (void)addButton:(NSString *)button withBlock:(void (^))block {
    [_blocks setObject:[block copy] forKey:button];
}

- (void)show {
    ... drawing stuff ...
    UIButton *button = ...
    [button addTarget:self selector:@selector(buttonPressed:) ...];
    ...
}

- (void)buttonPressed:(id)sender {
    ((void (^)())[_blocks objectForKey:[sender title]])();
}

, . , , buttonPressed: MyAlertView, . , MyAlertView . ARC , , -, , , . .

? MyAlertView , , (, ?).

+5
3

, , . , some , ) , ) , ) .

- . , (, ), , .

+7

, performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay, runloop.

, UIAlertView, .

UIAlertView.

+1

, . ARC , . , , . , , . , , ( ), .

, , -, . , . , , , , .

+1

All Articles