Check the nice clear tutorial at http://www.mikeash.com/pyblog/friday-qa-2011-09-30-automatic-reference-counting.html It spells out how to handle CF types in ARC.
On Oct 19, 2011, at 9:52 AM, Wade Tregaskis wrote: >> Following Cocoa convention you'd want to cast it to what and autorelease it? >> CGColorRef isn't toll-free bridged with anything. If you have been casting >> it to id and autoreleasing it you might have gotten away with that before >> but I don't think it's documented anywhere you can do that with CFTypes in >> general. > > You can. It may not be in the docs, but all CF types are also NSObjects (or > a subclass thereof). > >> You could change the semantics of the method to return a CFRetain()ed object >> and make it the responsibility of the caller to release it (and change the >> name of the method too to make it clear) or you can create a UIColor with >> your CGColorRef, then CFRelease() it and return the UIColor. >> >> Mixing autorelease and CFTypes does't seem like a great idea, but I'm >> prepared for someone to point out a whole piece of documentation I've never >> seen, that often seems to happen! > > No, mixing them is indeed a bad idea. CF doesn't have auto release pools, so > anything dealing with CF types is free to not think about them, and in > practice often does. I would go with explicitly returning the CGColorRef > retained. > _______________________________________________ _______________________________________________ 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