为什么这个方法从不调用?谁能帮我检查我的代码,我是新手。
这是我的 *.h 文件
@interface LoginViewController : UIViewController <FBSessionDelegate,FBRequestDelegate,FBDialogDelegate> {
Facebook *facebook;
IBOutlet UITextField *_txt;
NSString *facebookUserID;
我想获取 faceboo 用户 ID,所以我调用了 API '[facebook requestWithGraphPath:@"me" andDelegate:self];'
- (void) fbDidLogin
{
NSLog(@"[LOGIN] Used did login");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
// User has logged in to Facebook, now get their userId from Facebook
[facebook requestWithGraphPath:@"me" andDelegate:self];
}
我知道下面的方法会获取用户 ID,但它从未调用过。
- (void)request:(FBRequest *)request didLoad:(id)result
{
NSLog(@"Inside didLoad");
if ([result isKindOfClass:[NSArray class]])
{
result = [result objectAtIndex:0];
}
// When we ask for user infor this will happen.
if ([result isKindOfClass:[NSDictionary class]])
{
//NSDictionary *hash = result;
NSLog(@"Name: %@", [result objectForKey:@"name"]);
self.facebookUserID = [result objectForKey:@"id"];
NSLog(@"ID: %@", [result objectForKey:@"id"]);
}
}