2012-05-03 12 views
-1

グラフAPIを使って作業を開始しましたが、グラフ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"); 
} 

答えて

2

私が見たものから - あなたのアプリデリゲートを初期化していないように見えます。線に沿って

何か:

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

あなたappDelegate変数が初期化されていない - そうnilがあります。

注:私はあなたが他の場所でアプリケーションデリゲートを初期化していないという前提でこれをベースにしています。

関連する問題