MVC, Singleton, Delegate, NSNotificationCenter

It's hard to come up with a correct design pattern for you program. One of the useful one is NSNotificationCenter where you can access a selector from anywhere in your code.


Create a notification:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod) name:@"myNotification" object:nil];

Call it from anywhere in your code:

[[NSNotificationCenter defaultCenter] postNotificationName:@"myNotification" object:nil userInfo:nil];

No comments:

Post a Comment