• 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: CFDictionarySetValue and ARC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CFDictionarySetValue and ARC


  • Subject: Re: CFDictionarySetValue and ARC
  • From: Roland King <email@hidden>
  • Date: Mon, 17 Oct 2011 20:03:01 +0800

On Oct 16, 2011, at 2:15 PM, Quincey Morris wrote:

> On Oct 15, 2011, at 20:20 , Roland King wrote:
>
>> -(void)addView:(UIView *)view forElement:(id)element
>> {
>> 	CFDictionarySetValue( viewToElementMap, (__bridge id)view, (__bridge id)element );
>> }
>>
>> gives me
>>
>> error: incompatible types casting 'UIView *__strong' to 'id' with a __bridge cast [4]
>
> Look in 3.2.4 of the ARC document:
>
> 	http://clang.llvm.org/docs/AutomaticReferenceCounting.html#objects.operands.casts
>
> 'UIView*' is a retainable pointer type, so you must bridge it to a non-retainable pointer type -- in this case, you want 'const void *' because that's the type of the parameter you're passing:
>
>> 	CFDictionarySetValue( viewToElementMap, (__bridge const void *)view, (__bridge const void *)element );
>
> That compiles without error for me. Note that both of your casts were wrong. The error message on the 3rd parameter didn't appear until the error on the 2nd parameter was corrected.
>
>

Thanks Quincey, I'd managed to get myself hopelessly confused and fixated on (__bridge id), partly from reading a thread in the dev forums which was clearly just wrong. Working now.

All those __bridge calls made my code look really craptastic so I ended up factoring it out into its own class and hiding it in one implementation file, much better. _______________________________________________

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: 
 >CFDictionarySetValue and ARC (From: Roland King <email@hidden>)
 >Re: CFDictionarySetValue and ARC (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Mac core data and iCloud example app
  • Next by Date: "Using Drag and Drop in Tables" link gone?
  • Previous by thread: Re: CFDictionarySetValue and ARC
  • Next by thread: Re: CFDictionarySetValue and ARC
  • Index(es):
    • Date
    • Thread