2017-05-16 3 views
0

endTurnWithNextParticipants 오류가 발생한 경우를 처리하고 싶습니다. 따라서이 게시물의 끝에 cacheFailedEndTurnWithNextParticipants 메서드를 호출하여 데이터를 저장합니다. 나는 단지 참고 용으로이 기능을 제공했다.재시도 endTurnWithNextParticipants

문제는 uncache 방법으로 데이터를 복원하는 방법을 모르겠다는 것입니다. nextParticipants 목록에 GKTurnBasedPlayers을로드하려면 어떻게해야합니까? 지금 GKPlayer::loadPlayersForIdentifiers 사용하지만, 나는 다음과 같은 경고 얻을 :

"/Users/eternity/Documents/Xcode/DominationSK/DominationSK/GKMatchCache.m:134:74: Incompatible pointer types sending 'NSArray<GKPlayer *> * _Nullable' to parameter of type 'NSArray<GKTurnBasedParticipant *> * _Nonnull'" 

어떻게 ID의에서 GKTurnBasedParticipants을로드 할 수 있습니까?

이 재전송을 다른 방식으로 수행해야합니까?

-(void)uncache 
{ 
    if (_cache.count > 0) 
    { 
    NSDictionary *d = _cache[0]; 
    [_cache removeObjectAtIndex:0]; 

    [GKTurnBasedMatch loadMatchWithID:d[MATCH_ID] 
       withCompletionHandler:^(GKTurnBasedMatch * _Nullable match, NSError * _Nullable error) { 
        if (error == nil) 
        { 
bad load method --> [GKPlayer loadPlayersForIdentifiers:d[PARTICIPANTS] 
            withCompletionHandler:^(NSArray<GKPlayer *> * _Nullable nextParticipants, NSError * _Nullable error) { 
            if (error == nil) 
            { 
             NSNumber *timeout = d[TIMEOUT]; 
warning -->       [match endTurnWithNextParticipants:nextParticipants 
                  turnTimeout:timeout.longValue 
                   matchData:d[DATA] 
                 completionHandler:^(NSError * _Nullable error){ 
                 // This is not finished 
                 }]; 

            } 
            else 
            { 
             [self addToCache:d]; // TODO: Add time to live 
            } 
            }]; 
        } 
        else 
        { 
        [self addToCache:d]; // TODO: Add time to live 
        } 
       }]; 
    } 
} 

// Just for reference 
-(void)cacheFailedEndTurnWithNextParticipants:(GKTurnBasedMatch*)match 
           participants:(NSArray<GKTurnBasedParticipant*>* _Nonnull)nextParticipants 
            turnTimeout:(NSTimeInterval)timeout 
            matchData:(NSData* _Nonnull)matchData 
             error:(NSError* _Nonnull)error 
{ 
    if ([self shallBeCached:error]) 
    { 
    NSMutableArray *playerIds = [[NSMutableArray alloc] init]; 
    for (GKTurnBasedParticipant *p in nextParticipants) 
    { 
     [playerIds addObject:p.player.playerID]; 
    } 
    NSDictionary *d = @{MATCH_ID : match.matchID, 
         PARTICIPANTS : playerIds, 
         TIMEOUT : [NSNumber numberWithLong:timeout], 
         DATA : matchData}; 

    [self addToCache:d]; 
    } 
} 

답변

0

일치 항목에서 참가자를 가져온 다음 해당 배열에서 플레이어 ID를 검색하고 마지막으로 일치 항목의 참가자 속성을 업데이트 할 수 있습니다.