In a class when a method is performed, I have put this:
[[NSNotificationCenter defaultCenter] postNotificationName:@"locationFromZipFound" object:array];
and in the class that I wish to recieve the notification I have this:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getZipLocation:)
name:@"locationFromZipFound"
object:nil];
The problem is, this is never called:
-(void)getZipLocation:(NSNotification *)notification; {
NSLog(@"Zip received and put into array!");
NSArray *location = [notification object];
}
Any ideas? Thanks in advance.
I copy and pasted your code and it works great for me.
I put the postNotification
on a Button and the addObserver
on viewDidAppear:animated
.