puremvc-objectivec-standard-framework icon indicating copy to clipboard operation
puremvc-objectivec-standard-framework copied to clipboard

integration of a NSObject+Mediator category

Open treppa opened this issue 11 years ago • 0 comments

The following changes have been made

  • Added the NSObject+Mediator category. This enables any class to communicate with the pureMVC framework using method signatures from the IMediator protocol. Additionally, the category provides -(void)register and -(void)unregister methods for registering and unregistering ViewControllers / IMediators with the View.
    Note: Only ViewControllers or other classes representing the presentation layer should implement the NSObject+Mediator category.
  • the Mediator class is being removed
  • (void)notifyObserver:(id)notification now ignores the leak warning from xcode
  • The method signatures -(id)viewComponent and code>-(void)setViewComponent:(id)viewComponent have been removed from the IMediator protocol since they are redundant now.
  • The method +(NSString *)NAME within Proxies and NSObject+Mediator now return their classnames using NSStringFromClass([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+Mediator category within all ViewController classes, that need to receive or send Notifications from or to pureMVC
  • refactor all Mediator methods to your UIViewController
  • remove all Mediators and their references including their Facade registrations in your entire code
  • get rid of your Mediator / UIViewController communication 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/

treppa avatar Feb 05 '14 16:02 treppa