On 30 October 2011 15:15, Matt Neuburg <m...@tidbits.com> wrote: > In ARC, this is legal: > > self.view.layer.contents = (id)[[UIImage imageNamed:@"boat.gif"] CGImage]; > > And this is legal: > > id ref = (id)[[UIImage imageNamed:@"boat.gif"] CGImage]; > self.view.layer.contents = ref; > > But this is not: > > CGImageRef ref = [[UIImage imageNamed:@"boat.gif"] CGImage]; > self.view.layer.contents = (id)ref; // compilation fails > > In the last case, I have to change id to __bridge id. My question is: What's > the difference in the cases? In all situations I'm casting a CGImageRef to an > id, so why does ARC permit this in the first cases but not in the last? Is it > because UIImage's CGImage method is a method, and this fact somehow gives ARC > further info? Thx - m.
The compiler knows how to handle CF objects returned from Cocoa methods, but doesn't know how to handle stuff created by yourself. I thought that was fairly obvious from and explicit in the Transitioning Notes? Cheers, -- Igor ;-) _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com