Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook IOS SDK trying to make singleton class?
    text
    copied!<p>Hy, i am trying to make from Facebook IOS SDK (Octomber 2011) a class of my own in where i can make all the methods and functions that i need and just import this class in any of my application view controllers and call it. So this way i don't need to do all the initialization and delegation to the controllers in where i use the facebook. So i want to do like this, [myfacebookclass initwithappID:myappid] [myfacebookclass postmessage:@"some message"];</p> <p>The thing is when i am seting authorizeWithFBAppAuth:YES safariAuth:YES flags in facebook.m ( the original class) and i do a postmessage it redirects me on Facebook Application or Safari and check's for permision, i hit ok and then redirects me in my application and doesn't post message.</p> <p>WHen i am trying to post message i do like this :</p> <p>This is in my own facebook class</p> <pre><code>myfacebookclass *facebook2; +(void)initWithAppID:(NSString*) facebookAppId { if (facebook2 == nil) { facebook2 = [myfacebookclass new]; [facebook2 setWithAppId:facebookAppId]; } } - (void) postMessage1:(NSString *)messageToPost { if ([self.facebook isSessionValid]) { NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: self.applicationID, @"api_key", messageToPost, @"message", nil]; [self.facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; } else { NSArray * neededPermissions = [[[NSArray alloc] initWithObjects:@"user_about_me", @"publish_stream", nil] autorelease]; [self.facebook authorize:neededPermissions]; } } + (void)postMessage:(NSString*) message { [facebook2 postMessage1:message]; } </code></pre> <p>I also implemented: </p> <blockquote> <ul> <li>(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [facebook handleOpenURL:url]; }</li> </ul> </blockquote> <p>i've didn't modified facebook.m or other classes in Facebook IOS SDK.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload