-1

我刚开始使用 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");
}
4

1 回答 1

2

从我所看到的 - 看起来你还没有初始化你的应用程序委托。

类似的东西:

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

您的 appDelegate 变量尚未初始化 - nil 也是如此。

注意:我是基于您尚未在其他任何地方初始化应用程序委托的假设。

于 2012-07-25T18:47:21.027 回答