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 protected])
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> https://lists.apple.com/mailman/options/objc-language/remy.demarest%40gmail.com
>>>>>
>>>>> This email sent to [email protected]
>>>>
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Objc-language mailing list ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/objc-language/jimdovey%40mac.com
>>>
>>> This email sent to [email protected]
>>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Objc-language mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/objc-language/agrosam%40onlinehome.de
>
> This email sent to [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]