2012-07-22 90 views
-1

因此,基本上我的接口中有一个协议,我需要包含在我的实现中,因为我得到一个不完整的错误,因此无法继续。Cocos2d,需要在我的实现文件中包含协议

。 .h文件

@interface waveLayer1 : CCLayer <GameKitHelperProtocol> 
{ 
    ... 
} 

.m文件

@implementation waveLayer1 

GameKitHelper.h文件

#import "cocos2d.h" 
#import <GameKit/GameKit.h> 
@protocol GameKitHelperProtocol 
-(void) onLocalPlayerAuthenticationChanged; 
-(void) onFriendListReceived: (NSArray*)friends; 
-(void) onPlayerInfoReceived:(NSArray*)players; 
@end 

@interface GameKitHelper : NSObject { 
    id<GameKitHelperProtocol> delegate; bool isGameCenterAvailable; NSError* lastError; 
} 
@property (nonatomic, retain) id<GameKitHelperProtocol> delegate; 
@property (nonatomic, readonly) bool isGameCenterAvailable; @property (nonatomic, readonly) NSError* lastError; 

+(GameKitHelper*) sharedGameKitHelper; 
// Player authentication, info 
-(void) authenticateLocalPlayer; 
-(void) getLocalPlayerFriends; 
-(void) getPlayerInfo:(NSArray*)players; 
@end 

的错误是我有更多的文件,我可以显示 “未实现的协议方法”,但节省空间我决定看看你是否可以帮助我解决这个问题只用这些代码

回答

0

实现你的waveLayer1类这3种方法..

-(void) onLocalPlayerAuthenticationChanged; 
-(void) onFriendListReceived:(NSArray*)friends; 
-(void) onPlayerInfoReceived:(NSArray*)players; 
1
@interface waveLayer1 : CCLayer <GameKitHelperProtocol> 

这就是说“wavelayer1”实现了协议“GameKitHelperProtocol”。

Method in protocol not implemented 

表示在协议中声明的方法尚未实现。很有可能你忘了实现其中一个“GameKitHelperProtocol”方法,这会使你的类不实现该协议,这违反了你所做的声明,导致编译器输出一个错误。

0

当您声明一个类采用协议时,您必须为该协议中定义的所有必需方法编写一个实现。所以在这种情况下,您需要添加在GameKitHelperProtocol中定义的方法实现。