-1

つまり、基本的に、インターフェイス内にプロトコルがあり、不完全なエラーが発生して続行できないため、実装に含める必要があります。

。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  

エラーは「プロトコルのメソッドが実装されていません」です。表示できるファイルが他にもありますが、スペースを節約するために、これらのコードだけでこれを修正できるかどうかを確認することにしました。

4

3 に答える 3

1
@interface waveLayer1 : CCLayer <GameKitHelperProtocol>

これは、「wavelayer1」がプロトコル「GameKitHelperProtocol」を実装していることを示しています。

Method in protocol not implemented

プロトコルで宣言されたメソッドが実装されていないことを示します。「GameKitHelperProtocol」メソッドの1つを実装するのを忘れた可能性があります。これにより、クラスはそのプロトコルを実装しなくなり、宣言に違反し、コンパイラがエラーを出力します。

于 2012-07-22T10:45:01.270 に答える
0

クラスがプロトコルを採用することを宣言するときは、そのプロトコルで定義されているすべての必要なメソッドの実装を作成する必要があります。したがって、この場合、で定義されているメソッド実装を追加する必要がありますGameKitHelperProtocol

于 2012-07-22T10:45:28.093 に答える
0

これらの3つのメソッドをwaveLayer1クラスに実装します。

-(void) onLocalPlayerAuthenticationChanged;
-(void) onFriendListReceived:(NSArray*)friends;
-(void) onPlayerInfoReceived:(NSArray*)players;
于 2012-07-22T10:45:52.523 に答える