Reputation: 19479
If a Delegate method is not getting called, then what all things needs to be checked just to ensure that delegate is referenced in the viewController?
Upvotes: 4
Views: 2367
Reputation: 17012
If delegate methods aren't getting called when you are expecting them to, it's possible that you haven't actually hooked up the delegate. This can be done either in code, or in interface builder. For example, a UITableView
in interface builder can have its dataSource
and delegate outlets attached to a target, for example "File's owner".
Upvotes: 0
Reputation: 9126
Well, for a start you have to conform to the protocol in your header:
@interface MyViewController : UIViewController <YOUR DELEGATE'S PROTOCOL HERE,
UITableViewDelegate>{
}
@end
That's the most common mistake, anyway.
Also just make sure that you're setting your delegate. Normally you can do that like this:
myObject.delegate = self;
Though some classes do it in the initalization:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MY APP"
message:@"HELLO"
delegate:self
cancelButtonTitle:@"CLOSE"
otherButtonTitles:nil];
Upvotes: 5