I am making an IPhone application in which I connect the Facebook.I am connecting it on button click of my first view controller.Now I add second button and open second view controller in this I want to show the list of my friends in alphabetical order.I search it on net but when I applied it in my application ,it crash on run time please help me-
in my delegate class
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
navController =[[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navController;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
[self.window makeKeyAndVisible];
return YES;
}
-(void)fbDidLogin
{
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
}
My second view controller in which I want to show the list of my friends in loading
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSArray *_permissions = [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access",@"read_friendlists",nil] retain];
[facebook authorize:_permissions];
facebook = [[Facebook alloc] initWithAppId:@"APP_ID_HERE" andDelegate:self];
[facebook requestWithGraphPath:@"me" andDelegate:self];
[facebook requestWithGraphPath:@"me/friends" andDelegate:self];
// NSMutableDictionary*params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"4",@"uids", @"name", @"fields", nil];
[facebook requestWithGraphPath:@"me/friends"
andParams:[ NSDictionary dictionaryWithObjectsAndKeys:@"picture,id,name,link,gender,last_name,first_name",@"fields",nil]
andDelegate:self];
}
Any help is appreciated.