I have a app that login to a website. I had problems because I checked if I was logged in before the asynchronous web request finished. So I "solved" this using notification to notify when the web request finished, and then continue to check if login was successful.
The problem is that the selector eventHandler is never called, so nothing is happening.
Code:
-(IBAction) login:(id)sender {
// Add notification to listen to
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(eventHandler)
name:@"requestFinished"
object:nil];
}
-(void)eventHandler:(NSNotification *) notification {
NSLog(@"LoginViewController: Request finished and event triggered");
}
Code:
// Posting notification that the web request finished
[[NSNotificationCenter defaultCenter]
postNotificationName:@"requestFinished" object:nil];
Have I misunderstood the concept of notification or is something else wrong?