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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com