0

インターネット接続が必要な iOS のゲームに取り組んでいます。私が抱えている問題は、プレーヤーが再生を停止したときにサーバー (parse.com) に Bool を設定することです。今、私はこれをやっています...

-(void)applicationDidEnterBackground:(UIApplication *)application
{
    NSLog(@"Player logged out");
    [self playerLoggedOut];
}

-(void)playerLoggedOut
{
    PFUser *currentUser = [PFUser currentUser];

    if (currentUser) {

        [currentUser setObject:[NSNumber numberWithBool:NO] forKey:@"playing"];

        [currentUser saveEventually];
        [sharedInstance requestSentWithDesc:@"Player logged out"];
    }
}

しかし、それは機能していないようです。上記が呼び出されることはないと私が信じているときに、ゲームがクラッシュする状況もあります。

また...

-(void)applicationWillTerminate:(UIApplication *)application

しかし、それがいつ呼ばれたのかわかりません。

タイマーを使用する可能性はありますが、プレイヤーが二度とログインしない場合、または長期間ログインしない場合、タイマーをどのように使用できるかわかりません。

4

2 に答える 2

0

ゲームがクラッシュしている場合は、次のようなログを取得する必要があり ここに画像の説明を入力 ます。orメソッドNSLog(@"worked to the bitter end!");の最後に追加できます。-(void)playerLoggedOutrequestSentWithDesc

于 2013-08-20T17:04:33.397 に答える