Monday, March 7, 2016

Listening to all the notifications in your app

Sometimes you need to use other peoples code, sometimes you don't get to see their code (eg frameworks). Sometimes you want / need to see what is happening under the covers.

Here is a nice link that shows how to do it.
http://samjarman.co.nz/blog/quick-tip-listen-to-all-the-notifications/

in short;
NSNotificationCenter *notifyCenter = [NSNotificationCenter defaultCenter];
[notifyCenter addObserverForName:nil
object:nil
queue:nil
usingBlock:^(NSNotification* notification){
// Explore notification
NSLog(@"Notification found with:"
"\r\n name: %@"
"\r\n object: %@"
"\r\n userInfo: %@",
[notification name],
[notification object],
[notification userInfo]);
}];