IPhone SDK: Delegation Method Not Called - Troubleshooting

If the Delegate method is not called, then all things need to be checked only to ensure that the delegate is referenced in viewController?

+4
source share
2 answers

Well, first you need to follow the protocol in your header:

@interface MyViewController : UIViewController < YOUR DELEGATE PROTOCOL HERE , 
UITableViewDelegate>{ } @end

This is the most common mistake, anyway.

Also just make sure you install the delegate. You can usually do this as follows:

 myObject.delegate = self; 

Although some classes do this upon initialization:

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MY APP" 
message:@"HELLO"
delegate: self
cancelButtonTitle:@"CLOSE"
otherButtonTitles:nil];
+5
source

If delegate methods are not called when you expect them, you may not actually have connected a delegate. This can be done either in code or in the interface builder. For example, a UITableView in an interface builder can have its own dataSource and delegate outputs attached to the target, for example, “file owner”.

0
source

Source: https://habr.com/ru/post/1340756/


All Articles