2016-12-01 11 views
0

解析ユーザーの値を保存すると、最初に機能しますが、アプリケーションを閉じてもう一度開くと、再び機能しません。ユーザーを変更できませんParse

これは大丈夫

PFUser.current()["about"] = textfield.text 
PFUser.current().saveInBackground() 

を思わ私が使用して保存したコードであり、これは、現在のユーザーにオブジェクトを保存しようとしたときに私が取得エラーです。

PFKeychainStore failed to set object for key 'currentUser', with error: -34018 
or 
cannot modify user objectIDxx 

これは私が代わりにparse.com

答えて

1

の解析サーバーをインストールした後、あなたが前に「取消セッション」を使用していたが起こって始めましたか?そうでない場合、parse-serverはそれらを使用する必要があります。移行チュートリアルhereを確認することができます。

あなたがパースを初期化した後、これを追加する必要があります。

[PFUser enableRevocableSessionInBackground] 

そして、あなたはパースから「無効なセッションのエラーを取得した場合、あなたは再ログインユーザーする必要があります。

// Swift 
class ParseErrorHandlingController { 
    class func handleParseError(error: NSError) { 
    if error.domain != PFParseErrorDomain { 
     return 
    } 

    switch (error.code) { 
    case kPFErrorInvalidSessionToken: 
     handleInvalidSessionTokenError() 

    ... // Other Parse API Errors that you want to explicitly handle. 
    } 

    private class func handleInvalidSessionTokenError() { 
    //-------------------------------------- 
    // Option 1: Show a message asking the user to log out and log back in. 
    //-------------------------------------- 
    // If the user needs to finish what they were doing, they have the opportunity to do so. 
    // 
    // let alertView = UIAlertView(
    // title: "Invalid Session", 
    // message: "Session is no longer valid, please log out and log in again.", 
    // delegate: nil, 
    // cancelButtonTitle: "Not Now", 
    // otherButtonTitles: "OK" 
    //) 
    // alertView.show() 

    //-------------------------------------- 
    // Option #2: Show login screen so user can re-authenticate. 
    //-------------------------------------- 
    // You may want this if the logout button is inaccessible in the UI. 
    // 
    // let presentingViewController = UIApplication.sharedApplication().keyWindow?.rootViewController 
    // let logInViewController = PFLogInViewController() 
    // presentingViewController?.presentViewController(logInViewController, animated: true, completion: nil) 
    } 
} 

// In all API requests, call the global error handler, e.g. 
let query = PFQuery(className: "Object") 
query.findObjectsInBackgroundWithBlock { (objects: [AnyObject]!, error: NSError!) -> Void in 
    if error == nil { 
    // Query Succeeded - continue your app logic here. 
    } else { 
    // Query Failed - handle an error. 
    ParseErrorHandlingController.handleParseError(error) 
    } 
} 
+0

はい私はこれを試みましたが、まだ起こって、私のアプリを削除し、新しいアカウントを作成しました。正確に何が間違っているのか分かりません。 – TestDjay

関連する問題