LoginSignup
13
13

More than 5 years have passed since last update.

ios7からのGameCenter

Last updated at Posted at 2014-01-01

ios7以上対応のアプリを作成する際にGameCenterを使用したのでメモ

ios7からなんか変わってしまっていた。
点数を送信する際のメモです

ios6まで

ios6.m
//最初にアプリ内でGameCenterにログインしておく
GKScore *scoreReporter=[[GKScore alloc] initWithCategory:@"カテゴリのID"];
scoreReporter.value = 100;//点数
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
   if (error) { /* エラー処理 */ }
}];

ios7

ios7.m
//最初にアプリ内でGameCenterにログインしておく
GKScore *scoreReporter=[[GKScore alloc] initWithLeaderboardIdentifier:@"カテゴリのID"];
scoreReporter.value = 100;//点数
NSArray *scorearray=[[NSArray alloc]initWithObjects:scoreReporter, nil];//入れたい点数を配列に入れる。
[GKScore reportScores:scorearray withCompletionHandler:^(NSError *error) {
   if (error) { /* エラー処理 */ }
}];

簡単に言うと、少しAPIが変わって、1つ1つ送信するのではなく、配列で渡せるようになった。

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13