Re: when __bridge isn't required

2013-07-28 Thread Charles Srstka
On Jul 27, 2013, at 2:05 PM, Zac Bowling z...@zacbowling.com wrote: The first one is a NSConstantString string. It's not like a malloc'd NSString. It's effectively a singleton. It doesn't mater how it's bridged because it can't be released. The second is a new NSURL that is allocated on

when __bridge isn't required

2013-07-27 Thread Matt Neuburg
I feel like I've asked this before, but I don't feel I'm grasping the answer. Why don't these work the same way under ARC: NSString* answer = @42; int ans = CFStringGetIntValue((CFStringRef)answer); and NSURL* imageSource = [NSURL new]; CGImageSourceRef src =

Re: when __bridge isn't required

2013-07-27 Thread Robert Martin
My take: __bridge means 'do not transfer the retain count of whatever on the RHS to the LHS'. If the RHS involves some kind of create or new, then you'll get a leak since ARC won't release it. __bridge_transfer means 'transfer the retain count of whatever on the RHS to the LHS'. If the RHS

Re: when __bridge isn't required

2013-07-27 Thread Tom Davie
The first gives me the following error: Implicit conversion of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast Tom Davie On Jul 27, 2013, at 8:31 PM, Matt Neuburg m...@tidbits.com wrote: I feel like I've asked

Re: when __bridge isn't required

2013-07-27 Thread Zac Bowling
The first one is a NSConstantString string. It's not like a malloc'd NSString. It's effectively a singleton. It doesn't mater how it's bridged because it can't be released. The second is a new NSURL that is allocated on the heap. It needs to be released so it needs to be bridged correctly to

Re: when __bridge isn't required

2013-07-27 Thread Quincey Morris
On Jul 27, 2013, at 11:54 , Robert Martin robmar...@frontiernet.net wrote: But CGImageSourceCreateWithURL() includes the keyword 'create' - so the object you get back has a retain count of 1. ARC will insist that you cast with __bridge or __bridge_transfer. ARC isn't involved with the

Re: when __bridge isn't required

2013-07-27 Thread Matt Neuburg
Argh. Okay, I'll ask this on devforums when it comes back up, in case it depends on, uh, the thing I'm using that I can't talk about. m. On Jul 27, 2013, at 12:10 PM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: I tried both your examples in Xcode 4.6.3 and OS X 10.8 SDK, and