How do I make the same Facebook object available to all my code in my iOS Facebook SDK project?

Up vote 0 down vote favorite share g+ share fb share tw.

I've tried passing in the Facebook object which I named facebook as an argument into classes that rely on it. However, is there a way to use it in a sort of global way so that way I don't have to keep on passing it around between objects? Iphone facebook sdk ios link|improve this question asked Oct 23 '10 at 19:00Anthony Glyadchenko4641625 82% accept rate.

It would be best to mark a question as the answer or add more details if the answers provided are not enough. – Spyker Nov 5 '10 at 9:19.

Well, I see several ways: Create a public static method in a class that contains facebook object: + (id)getSharedFacebookObject { return facebook; } The second way is to use app delegate: MyAppDelegate *appDel = (MyAppDelegate *)UIApplication sharedApplication delegate; id Facebook = appDel.facebook.

Your best bet would be to use the singleton pattern. en.wikipedia.org/wiki/Singleton_pattern Create a new class that has the facebook object as an instance variable and set the new class as the facebook delegate. You can then get the sharedInstance from any class and it will return the same object.

This may not actually be the correct solution to your problem. It may require you to add another layer of communication between the singleton and the particular view controller you are using. If you are only performing simple functions then this may be fine.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions