-1

私はGraph APIを使い始めたばかりで、ログインできるようにしていますが、Graph 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 変数は初期化されていません。初期化もされていません。

注: これは、アプリ デリゲートを他の場所で初期化していないという前提に基づいています。

于 2012-07-25T18:47:21.027 に答える