2
我在我的应用程序中设置了Facebook iOS SDK。但是,我无法确定会话何时完成。如何检查它是否完成,以及在哪里(如何)存储登录接收的访问令牌?在Facebook iOS SDK中存储accessToken
我需要确定我是否有访问令牌或从一开始就没有,因此我知道是重新登录还是应用前进。
我在我的应用程序中设置了Facebook iOS SDK。但是,我无法确定会话何时完成。如何检查它是否完成,以及在哪里(如何)存储登录接收的访问令牌?在Facebook iOS SDK中存储accessToken
我需要确定我是否有访问令牌或从一开始就没有,因此我知道是重新登录还是应用前进。
您是否熟悉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];
希望它有帮助!
ONE得到偏好于“改编过的”在上面的例子中
二决定为自己的喜好的名称。 'storeTheStringHere'在示例中。
三使用stringForKey让你在这个例子中字符串 'whateverIDstring':
FOUR检查,如果它要么是零或空白。如果是这样,开始新鲜。
FIVE一旦你得到的值,保存为显示!
希望它有帮助!
此外,与Facebook iOS SDK一起提供的DemoApp也正是如此。 – Rog 2010-12-02 22:56:35