나는 조금 늦게 점프하고 있지만 세션을 만들 때 사용하는 컨테이너 이름을 세 번 확인합니다.
xCode의 키 - 값 저장, iCloud 문서 및 CloudKit의 세 가지 옵션이 모두 활성화되었습니다.
iCloud 드라이브를 사용하지 않습니다.
다음 코드는 초대장을 보낼 때마다 성공적으로 새 세션을 만듭니다. 새 세션을 인쇄 한 다음 해당 컨테이너 ID에 대한 모든 기존 세션을 반복합니다.
-(void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match
{
[self dismissViewControllerAnimated:YES completion:nil];
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSString *iCloudContainerName = [@"iCloud." stringByAppendingString: bundleIdentifier];
[GKGameSession createSessionInContainer:iCloudContainerName
withTitle:@"test"
maxConnectedPlayers:4
completionHandler:^(GKGameSession * _Nullable session, NSError * _Nullable error)
{
NSLog(@"(1) Session: %@, Error: %@", session.identifier, [error description]);
[GKGameSession loadSessionsInContainer:iCloudContainerName
completionHandler:^(NSArray<GKGameSession *> * _Nullable sessions, NSError * _Nullable error)
{
for (GKGameSession *session in sessions)
{
NSLog(@"(2) Session: %@, Error: %@", session.identifier, [error description]);
}
NSLog(@"-----");
}];
}];
}
iOS 10이 베타 상태가되면 바로이 기능을 사용할 수있었습니다. –
당신은 어디에서이 문서를 찾니? Apple 설명서에는 메소드 서명 만 있습니다. 이 API를 사용하는 방법에 대한 온라인 가이드가 있습니까? –
문서는 없지만 수업 및 방법은 매우 간단합니다. WWDC 2016 GameCenter 비디오로 시작, 세션 611 - https://developer.apple.com/videos/play/wwdc2016/611/ –