I’ve just downloaded the Facebook iOS SDK and I noticed that in the sample code that comes with the SDK whenever it creates an instance of the Facebook class it does it like this:
_facebook = [[[[Facebook alloc] init] autorelease] retain];
where _facebook is a member variable of the calling object (i.e. not a local variable).
Can anyone explain exactly what’s the point of autoreleasing and then retaining it?
It effectively does nothing beyond consuming some cycles and memory.
Or, more precisely, in a correctly written application, it does nothing. In an incorrectly written application, it might mask a bug by lengthening the lifespan of the
_facebookobject. However, it isn’t a real fix.I found a similar line of code in http://github.com/facebook/facebook-ios-sdk/blob/master/sample/DemoApp/Classes/DemoAppViewController.m If that is what you are referring to then, yes, it is nonsense.