Search code examples
objective-cobjectdelegatesself

Objective-C delegate or self is morphing classes


I have 2 UIViewControllers(A,B). A is set as the delegate for B and then B is presented. The protocol is set up in B's header:

@protocol BDelegate <NSObject>
- (IBAction)finishOrder:(id)sender;

@end

delegate property is declared:

@property (nonatomic, assign) id<BDelegate> delegate;

A sets B.delegate = self; Then on a button press B calls:

if (self.delegate) {
        [self.delegate finishOrder:nil];
    }

However, on first run lldb gives me:

-[UITextInteractionAssistant finishOrder:]: unrecognized selector sent to instance

second run:

-[NSInvocation delegate]: unrecognized selector sent to instance

third run:

-[__NSCFDictionary delegate]: unrecognized selector sent to instance

forth run:

-[UITextTapRecognizer finishOrder:]: unrecognized selector sent to instance

So... no code changed, but self changed from A to NSInvocation and __NSCFDictionary and the delegate for B (self of A) changed to UITextInteractionAssistant and UITextTapRecognizer... Never seen anything like it. Any ideas? Thanks!


Solution

  • You are over-releasing somewhere. Try turning on Zombies, and use Instruments to track down the over-release.