Search code examples
iosxcodefacebooksharekit

ShareKit 2.0 facebook share URL


I have the following code for sharing with facebook using ShareKit:

-(void)buttonAction:(id)sender
{
[SHK setRootViewController:self];
SHKItem *facebookItem = [[SHKItem alloc] init];

    facebookItem = [SHKItem URL:[NSURL URLWithString:@"www.google.com"] title:@"Some test title"];

    facebookItem.facebookURLSharePictureURI = @"www.myTestPicture.com";

   facebookItem.facebookURLShareDescription = @"Custom share description";


    [SHKFacebook shareItem:facebookItem];
}

Everything works fine except for one scenario. My application has a log out button. Upon hitting this button, all the data save in NSUserDefaults gets erased. So, I log in and then make a post to facebook. Then, I log out (erase all the data) and afterwards log back in with facebook. Everything works so far. However if I try to make another post to facebook at this point, my application crashes with no error showing up in the console. If I restart the application and try to make the same post again, it works. It only crashed after loging out, back in (with facebook) and then trying to make the post. Any clues? Thanks.

EDIT: Seems like it is crashing in FBDialog at line 341:

_webView = [[UIWebView alloc] initWithFrame:CGRectMake(kPadding, kPadding, 480, 480)];

Solution

  • Ok, so after some digging aroung here, it seems to be Apple's bug in iOS 5.1 according to Why does clearing NSUserDefaults cause EXC_CRASH later when creating a UIWebView?