Personal Project

Sunday, October 13, 2013

PROTOCOLS


In Objective C, an object cannot inherit from multiple superclasses, yet it can conform to multiple protocols.  If you need a GameCenterManageDelegate to be inherited by many Views, you can define as shown below.

GameCenterManagerDelegate.h
@protocol GameCenterManagerDelegate <NSObject>
@optional
- (void) processGameCenterAuth: (NSError*) error;
@end

GameCenterManagerDelegate.m
@implementation GameCenterManager
// ... 
@end


GameViewController.h
@interface GameViewController : ViewController <GameCenterManagerDelegate> 


@end

No comments:

Post a Comment