views:

60

answers:

3
- (IBAction) someButtonCall {

        if(!someCondition) {
            someButtonCallBack = @selector(someButtonCall);
            [self presentModalViewController:someController animated:YES]; 
        } else
        ...
}

//Called from someController
- (void) someControllerFinished:(BOOL) ok {
   [self dismissModalViewControllerAnimated:YES];
   if(ok) [self performSelector:someButtonCallBack];
   else ...
}

I'm wondering if the user keeps getting into the !someCondition clause if the selector is leaked by assigning a new selector each time (the code above is hypothetical and not what i'm doing).

Any help is appreciated.

Thanks, James Jones

A: 

The SEL type is simply a C string, so you won't have memory leaks whit re-assignations.

Marco Mustapic
A: 

This example does not leak memory. @selector() is evaluated at compile time. You could possibly leak a SEL variable, but not the selector itself.

NSResponder
+2  A: 

No, this doesn't leak anything - you don't own the SEL values returned by @selector() and sel_registerName(), the Objective-C runtime does.

Georg Fritzsche