How to post and receive an NSNotifications (Objective C) | Notifications (in Swift)?
Send a notification:
[[NSNotificationCenter defaultCenter] postNotificationName:@"MyCacheUpdatedNotification" object:self];
Receive it:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cacheUpdated:) name:@"MyCacheUpdatedNotification" object:nil];
Act on it:
- (void)cacheUpdated:(NSNotification *)notification {
[self load];
}
And dispose of it:
[[NSNotificationCenter defaultCenter] removeObserver:self];