puremvc-objectivec-standard-framework
puremvc-objectivec-standard-framework copied to clipboard
integration of a NSObject+Mediator category
The following changes have been made
- Added the
NSObject+Mediatorcategory. This enables any class to communicate with the pureMVC framework using method signatures from theIMediatorprotocol. Additionally, the category provides-(void)registerand-(void)unregistermethods for registering and unregistering ViewControllers / IMediators with theView.
Note: Only ViewControllers or other classes representing the presentation layer should implement theNSObject+Mediatorcategory. - the
Mediatorclass is being removed (void)notifyObserver:(idnow ignores the leak warning from xcode)notification - The method signatures
-(id)viewComponentand code>-(void)setViewComponent:(id)viewComponent have been removed from theIMediatorprotocol since they are redundant now. - The method
+(NSString *)NAMEwithinProxiesandNSObject+Mediatornow return their classnames usingNSStringFromClass([self class]) - documentation updated using doxygen 1.8.6
- header files updated
- code is converted to ARC
Note: Code that uses previous versions of pureMVC are not compatible with these changes.
Refactoring your code
- import the
NSObject+Mediatorcategory within all ViewController classes, that need to receive or send Notifications from or to pureMVC - refactor all
Mediatormethods to yourUIViewController - remove all Mediators and their references including their
Facaderegistrations in your entire code - get rid of your
Mediator/UIViewControllercommunication code, in case you have any - register / unregister your ViewControllers with the Facade like:
- (void)viewDidLoad {
[super viewDidLoad];
// register your ViewController / IMediator with the View
[self register];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// unregister your ViewController / IMediator from the View
[self unregister];
}
- register / retrieve a proxy like:
//register proxy with the Model
[self.facade registerProxy:[TestProxy proxy]];
// retrieve a proxy from the Model
id testProxy = [facade retrieveProxy:[TestProxy NAME]];
Examples
A description including visual diagrams and examples for ios and osx can be found at: http://www.reppa.net/puremvc-fur-ios-und-osx/