• 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: ARC: cast C-array of CFTypeRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC: cast C-array of CFTypeRef


  • Subject: Re: ARC: cast C-array of CFTypeRef
  • From: Andreas Grosam <email@hidden>
  • Date: Mon, 04 Jun 2012 18:43:54 +0200

On Jun 4, 2012, at 6:25 PM, Andreas Grosam wrote:

>
> On Jun 4, 2012, at 4:15 PM, Jim Dovey wrote:
>
>
> Eventually, I got this to "compile". Note sure if this ends up with correct code, though:

OK, this crashes badly, which is understandable :)

But there seems no way to get the pointer to buffer and make a bridge cast:
    typedef CFTypeRef* cf_pointer;

    id __unsafe_unretained* o = (__bridge __unsafe_unretained id)(buffer);
                                ^
Error: Incompatible types casting 'cf_pointer' (aka 'const void **') to '__unsafe_unretained id' with a __bridge cast


>
>
>
>
>>
>> On 2012-06-04, at 9:47 AM, Andreas Grosam wrote:
>>
>>>
>>> On Jun 4, 2012, at 3:40 PM, Remy Demarest wrote:
>>>
>>>> Use __bridge: (__bridge id *)buffer.
>>>
>>> No sorry, this doesn't work. The better way would have been
>>>
>>> (__bridge id __strong*)buffer
>>>
>>> but that doesn't work either.
>>>
>>> (both, issue compiler errors)
>>>
>>>
>>>
>>> Andreas
>>>
>>>>
>>>> Remy "Psy" Demarest
>>>>
>>>> Le 04 juin 2012 à 09:32, Andreas Grosam a écrit :
>>>>
>>>>> Under ARC, how do I cast an array of CF objects to an array of id objects?
>>>>>
>>>>> CFTypeRef* buffer = (CFTypeRef*)malloc(N*sizeof(CFTypeRef));
>>>>> for (int i = 0; i < N; ++i) {
>>>>> buffer[i] = … ;
>>>>> }
>>>>>
>>>>> For instance when passing the array of CF objects 'buffer' to a method which requires an array of id, e.g.:
>>>>>
>>>>> (non-ARC):
>>>>> NSArray* array = [[NSArray alloc] initWithObjects:(id*)buffer count:N];
>>>>>
>>>>>
>>>>>
>>>>> Andreas
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Objc-language mailing list      (email@hidden)
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>
>>>>> This email sent to email@hidden
>>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Objc-language mailing list      (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Objc-language mailing list      (email@hidden)
> 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


  • Prev by Date: Re: Localization based on location
  • Next by Date: NSTextView selection
  • Previous by thread: Re: Localization based on location
  • Next by thread: NSTextView selection
  • Index(es):
    • Date
    • Thread