共享实例注销不起作用。我知道这对开发人员来说是个大问题。有没有人有办法解决吗?感谢
答案 0 :(得分:6)
我在3个月前遇到过这个问题,刚刚找到了解决方法。显然,清除cookie实际上是为了以前登录用户的Twitter存储信息。下面的代码对我有用:
!警告!确保首次登录时禁止Twitter访问设备上的帐户。这会导致Twitter每次强制登录用户,而不是直接查看保存在设备中的Twitter帐户。希望这有帮助!
- (IBAction)twitterLogout:(id)sender {
[[Twitter sharedInstance] logOut];
[self.view insertSubview:_logoutTwitter atIndex:16];
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
{
NSString* domainName = [cookie domain];
NSRange domainRange = [domainName rangeOfString:@"Twitter"];
if(domainRange.length > 0)
{
[storage deleteCookie:cookie];
}
}
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com"];
NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];
for (NSHTTPCookie *cookie in cookies)
{
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
}