Reputation: 5403
I'm trying to integrate the Facebook SDK into an iOS5 project I'm building.
Following a piece of advice, I set the compiler flags on the Facebook specific files to '-fno-objc-arc'. This allows me to build the project successfully, while keeping ARC for my files.
I have gone through and implemented the basic Facebook SDK steps, and it is successfully logging in and setting permissions. The issue comes when I try and access the graph:
[facebook requestWithGraphPath:@"me/friends" andDelegate:(id)self];
The reason I am saying '(id)self' instead of just 'self' is the latter throws me the error:
warning: sending 'PhotoController *__strong' to parameter of incompatible type 'id<FBRequestDelegate>' [3]
I have implemented all the callback methods. The only method that is successfully called is
- (void)requestLoading:(FBRequest *)request;
The app crashes when it receives data, I assume.
Per suggestions in other threads I have turned on NSZombie and here's the results:
2011-11-14 13:40:29.896 Friend Carousel[9660:f803] facebook: <Facebook: 0x6e21550>
2011-11-14 13:40:29.898 Friend Carousel[9660:f803] self: <PhotoController: 0x6e215a0>
2011-11-14 13:40:31.115 Friend Carousel[9660:f803] *** -[PhotoController respondsToSelector:]: message sent to deallocated instance 0x6e215a0
Where facebook is the facebook object, and PhotoController is the delegate (with that method defined).
So it would seem that the Facebook Request object is trying to send a message to an already-released delegate. Right? And that's what causes the crash?
Unfortunately, this is where my iOS knowledge fails me; is this something that I'm doing wrong, or am I simply not able to incorporate the Facebook SDK into an ARC-enabled project (without heavy modification)? I'm just not really sure where to go from here.
Thanks,
Kevin
Upvotes: 0
Views: 881
Reputation: 11238
I'll take a stab here. My wild guess would be to look at where PhotoController is allocated. If it is not retained in an ivar and merely given to the Facebook object then it would make sense to crash as delegate properties are not supposed to be retained. In other words you can't rely on the Facebook object retaining the PhotoController as this is bad practice with delegate objects. (Delegates are supposed to be weak references.) Where ever the Facebook object is alloc'ed and retained you should probably retain a copy of the PhotoController as well and keep it around for the life of the Facebook object.
Upvotes: 1