• 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: to __bridge or not to __bridge?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: to __bridge or not to __bridge?


  • Subject: Re: to __bridge or not to __bridge?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Mon, 13 Feb 2012 18:09:12 +0100

Le 13 févr. 2012 à 16:56, Jean-Denis MUYS a écrit :

>
> On 13 févr. 2012, at 16:26, Thomas Clement wrote:
>
>> Doc says: "The compiler understands Objective-C methods that return Core Foundation types follow the historical Cocoa naming conventions"
>> This applies to case 1, not case 2.
>>
>
> Tadaa! This is it. If the CF type is not the variable, but the result of a Objective-C method, then the compiler refrains from complaining. I checked that this is the case for *any* Objective-C method, including @property getters. I also checked that the compiler will refrain from complaining even if the type is not a Core Foundation type, but a pointer to any C struct. So it seems that (at least currently), this sentence could be rewritten:
>
>
>> "The compiler **assumes** that **any** Objective-C methods that return **any pointers to struct** types follow the historical Cocoa naming conventions"
>
> Though of course, this compiler leniency cannot safely  be assumed to last.

Exactly.
Note that this leniency applies almost everywhere the compiler expect a CF based type (format string check for instance), not only for ARC, but this is a very bad idea to rely on this.
There is actually no reliable way to defined if a type is a CF based type, so clang just assume that all opaque types are CF based types for convenience, but don't expect it to remain true, and don't expect it to generate valid code.
It may probably end up generating calls to retain/release on your arbitrary struct which will cause your program to crash.

-- Jean-Daniel


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >to __bridge or not to __bridge? (From: Jean-Denis MUYS <email@hidden>)
 >Re: to __bridge or not to __bridge? (From: Thomas Clement <email@hidden>)
 >Re: to __bridge or not to __bridge? (From: Jean-Denis MUYS <email@hidden>)

  • Prev by Date: Re: to __bridge or not to __bridge?
  • Next by Date: Re: Where to install custom framework to support a plug-in architecture?
  • Previous by thread: Re: to __bridge or not to __bridge?
  • Next by thread: Ctrl-Drag from xib
  • Index(es):
    • Date
    • Thread