因此,基本上我的接口中有一个协议,我需要将其包含在实现中,因为我得到了一个不完整的错误,因此无法继续。
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
错误是"协议中的方法未实现"我有更多的文件可以显示,但为了节省空间,我决定看看你是否可以用这些代码
@interface waveLayer1 : CCLayer <GameKitHelperProtocol>
这说明"wavelayer1"实现了协议"GameKitHelperProtocol"。
Method in protocol not implemented
表示协议中声明的方法尚未实现。很可能您忘记实现其中一个"GameKitHelperProtocol"方法,这使得您的类没有实现该协议,这违反了您所做的声明,从而导致编译器输出错误。
在waveLayer1类中实现这3种方法。。
-(void) onLocalPlayerAuthenticationChanged;
-(void) onFriendListReceived:(NSArray*)friends;
-(void) onPlayerInfoReceived:(NSArray*)players;
当您声明一个类采用了一个协议时,您必须为该协议中定义的所有必需方法编写一个实现。因此,在这种情况下,您需要添加在GameKitHelperProtocol
中定义的方法实现。