• 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: Quincey Morris <email@hidden>
  • Date: Sat, 15 Oct 2011 23:15:41 -0700

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.


_______________________________________________

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

  • Follow-Ups:
    • Re: CFDictionarySetValue and ARC
      • From: Roland King <email@hidden>
References: 
 >CFDictionarySetValue and ARC (From: Roland King <email@hidden>)

  • Prev by Date: Re: ARC conversion issue problem with Xcode 4.2
  • Next by Date: Arcs and Bridges
  • Previous by thread: CFDictionarySetValue and ARC
  • Next by thread: Re: CFDictionarySetValue and ARC
  • Index(es):
    • Date
    • Thread