i am working with publishing story on facebook in my app. its my first time working with iphone app and facebook together. i read documentation and now i can get permissions to publish. but there is a problem. i have this code in AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
facebook = [[Facebook alloc] initWithAppId:@"app_id"];
NSArray* permissions = [[NSArray arrayWithObjects:
@"publish_stream", nil] retain];
[facebook authorize:permissions delegate:self];
return YES;
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
now i have a button in DetailView which should post story on user's wall. i wrote this code there:
SBJSON *jsonWriter = [[SBJSON new] autorelease];
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
[sTitle stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], @"name",
[sSummary stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], @"description",
[sLink stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], @"href", nil];
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"XXX", @"api_key",
@"Share on Facebook", @"user_message_prompt",
attachmentStr, @"attachment",
nil];
[facebook dialog:@"stream.publish" andParams:params andDelegate:self];
and it gives error facebook undeclared at the last line. how can i remove that error. should i init that facebook in DetailViewController too or can i use already declared facebook which is in AppDelegate.m. if yes how? thanx