質問

私が持っています Facebook iOS SDK 私のアプリでセットアップします。ただし、セッションがいつ終了するかを判断するのに苦労しています。終了したかどうか、およびログインで受信したアクセストークンをどこに保存するかを確認するにはどうすればよいですか?

最初からアクセストークンがあるかどうかを判断する必要があるので、再びログインするか、アプリで前進するかどうかがわかります。

役に立ちましたか?

解決

nsuserdefaultsに精通していますか?アプリの設定を保存するためです。

それらは非常に使いやすく、おそらくあなたが探しているものです。だからそれはただのようなものです。

NSUserDefaults *factoids;
NSString *whateverIDstring; // make this a property for convenience  

factoids = [NSUserDefaults standardUserDefaults];
self.whateverIDstring = [factoids stringForKey:@"storeTheStringHere"];

if ( ( whateverIDstring == Nil ) || ( [whateverIDstring isEqualToString:@""] ) )
    // it does not yet exist, so try to make a new one...
else
    // we already made one last time the program ran

// when you make a new one, save it in the prefs file like this...   
[factoids setObject:yourNewString forKey:@"storeTheStringHere"];
[factoids synchronize];

それが役に立てば幸い!

1 上記の例のように、「ファクトイド」への好みを取得します

2 あなたの好みの名前を決定します。例の「storethestringhere」。

stringforkeyを使用して、例で「whated whatedstring」を入手してください。

nilまたはblankのいずれかであるかどうかを確認してください。もしそうなら、新鮮に始めてください。

値を取得したら、図のように保存してください!

それが役に立てば幸い!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top