2012-05-03 6 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에 변수가 초기화되지 않은이 - 그래서 무기 호입니다.

참고 : 저는 다른 곳에서는이 앱 대리인을 초기화하지 않았다고 가정합니다.

관련 문제