2012-07-22 3 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에 정의 된 메소드 구현을 추가해야합니다.

관련 문제