• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: when __bridge isn't required
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: when __bridge isn't required


  • Subject: Re: when __bridge isn't required
  • From: Tom Davie <email@hidden>
  • Date: Sat, 27 Jul 2013 21:05:32 +0200

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 <email@hidden> wrote:

> 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 =
>        CGImageSourceCreateWithURL((CFURLRef)imageSource, nil);
>
> The first one compiles (with no explicit __bridge). The second one doesn't; you must say __bridge explicitly. But why? They look completely parallel to me.
>
> The mystery is compounded by the fact that if you omit the cast entirely in the first example, the compiler claims that you need a bridged cast. But you don't; you just need a cast. That feels like a bug; if a mere cast is sufficient, the compiler should say so (and Fix-It should offer it as a possible fix).
>
> m.
>
> --
> matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
> pantes anthropoi tou eidenai oregontai phusei
> Programming iOS 6! http://shop.oreilly.com/product/0636920029717.do
> 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

_______________________________________________

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


References: 
 >when __bridge isn't required (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: when __bridge isn't required
  • Next by Date: Re: when __bridge isn't required
  • Previous by thread: Re: when __bridge isn't required
  • Next by thread: Button on side menu not working
  • Index(es):
    • Date
    • Thread