我有 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];

希望能帮助到你!

如上所述,获取对“事实”的偏好

确定您的偏好名称。示例中的“遗产”。

在示例中使用StringForKey获取字符串“ whywingIdstring”:

四个 检查是零还是空白。如果是这样,请重新开始。

获得该值后,如图所示保存!

希望能帮助到你!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top