图API不起作用

时间:2012-05-03 13:57:58

标签: facebook-graph-api

我刚刚开始使用Graph API并让它能够登录,但不要进行图形api调用。我已经设置了委托(我认为),但它没有回调我实现的委托方法。这是我的代码:

#import <UIKit/UIKit.h>
#import "Profile.h"
#import "AppDelegate.h"
#import "FBRequest.h"
@interface HomeViewController : UITableViewController <FBRequestDelegate>
{
    Profile *profile;
    AppDelegate *appDelegate;
}
- (void)request:(FBRequest *)request didLoad:(id)result;

@end

实现:

- (void)viewDidLoad
{
    [super viewDidLoad];
    profile = [[Profile alloc] initWithUserId:1];
    [profile refreshMatchesWithCallback:^ 
     {
             [self.tableView reloadData];
     }];   

    [appDelegate.facebook requestWithGraphPath:[NSString stringWithFormat: @"me", appDelegate.facebook.accessToken] andDelegate:self];
    [[appDelegate facebook] requestWithGraphPath:@"me" andDelegate:self];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


- (void)request:(FBRequest *)request didLoad:(id)result {
    NSLog(@"%@", result);
}

- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
    NSLog(@"erre");
}

1 个答案:

答案 0 :(得分:2)

从我看到 - 看起来你没有初始化你的应用代表。

有些事情:

appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

您的appDelegate变量尚未初始化 - 因此为零。

注意:我的假设是你没有在其他地方初始化app delegate。