I was wondering what the “best practice” guidelines are for using the Facebook iOS SDK.
Specifically – I have several forms that use the Facebook SDK.
My initial instinct as an OOP programmer was to create a “FacebookManager” class under my data-access-layer which handles all Facebook activity.
Unfortunately since Facebook iOS SDK uses delegates and async methods, this is not so helpful since any other module using FacebookManager would have to pass in delegates for all responses anyway.
Then I figured that each ViewController would be a FBRequestDelegate by itself and handle all Facebook responses.
So, how do you do it in your app?
What I’ve done is to create a FacebookManager as you suggested. This manager becomes the FBRequestDelegate. Now I prefer blocks to the delegation model so all my FacebookManager methods are block based.
Here is what my post to a user’s wall method looks like
Then on a success or error I just execute the block
I wish there was a better way to deal with the block but that’s the best one I have found so far. Is this the best way to do it? Probably not but that’s what I currently use and it seems to be ok, keeping all the FB interaction away from my View Controllers.
Note all the code here assumes ARC that’s why there are no releases