minor ARC casting question
minor ARC casting question
- Subject: minor ARC casting question
- From: Matt Neuburg <email@hidden>
- Date: Sun, 30 Oct 2011 08:15:17 -0700
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.
--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden