0

I am using below code for auto share on facebook in my iPhone application, but my application get crashed with EXC_BAD_ACCESS message, when i tap share button.

NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:4];
[variables setObject:@"Yours content to be shared" forKey:@"message"];
// share prepared content to fb
fb_graph_response = [fbGraph doGraphPost:@"me/feed" withPostVars:variables];
NSLog(@"postMeFeedButtonPressed:  %@", fb_graph_response.htmlResponse);

help me out thanks in advance.

Muddu Patil
  • 713
  • 1
  • 11
  • 24
maddysan
  • 258
  • 2
  • 14

1 Answers1

1

It is hard to tell from your code provided, but one idea:
Your dictionary variables is created as an autorelease object. This means if it is not retained in fbGraph, it will be deallocated as soon as the app returns to the main run loop, in which tabbing the share button is handled. In this case, variables no longer exists after the button is pressed, and you will get an EXC_BAD_ACCESS error.
If you were using ARC, this will handled correctly by the compiler.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116