Re: NEWBIE: NSArray toll-free-bridged with CFArray?
Re: NEWBIE: NSArray toll-free-bridged with CFArray?
- Subject: Re: NEWBIE: NSArray toll-free-bridged with CFArray?
- From: ber <email@hidden>
- Date: Sat, 7 Sep 2002 20:05:47 -0400
For the benefit of the list, having replied only to Shawn. Thanks for
helping me understand that it
wants the address of the pointer to the NSArray but it still gives the
warning. I realize I can
make it go away with a cast but is it expected something that's
"toll-free-bridged" throw warnings about
being incompatible?
Thanks,
brian
On Saturday, September 7, 2002, at 07:50 PM, Shawn Erickson wrote:
On Saturday, September 7, 2002, at 04:20 PM, ber wrote:
In the following snippet the compiler issues:
Controller.m:15: warning: passing arg 1 of
`SecKeychainCopySearchList'
from incompatible pointer type
where line 15 is is the 2nd call to SecKeychainCopySearchList.
OSStatus ret;
CFArrayRef searchList;
NSArray *anotherSearchList;
ret = SecKeychainCopySearchList(&searchList);
ret = SecKeychainCopySearchList(anotherSearchList);
The declaration for SecKeychainCopySearchList is:
OSStatus SecKeychainCopySearchList(
CFArrayRef *searchList);
NSArray tells me "... in an API where you see a CFArrayRef parameter,
you can pass in an NSArray instance."
I apparently don't know what an "NSArray instance" is. What am I
doing
wrong that generates the warning?
The ivar anotherSearchList is not an instance of an NSArray it is a
pointer to a NSArray, in this case an uninitialized pointer. Anyway...
this is ok because the function will fill in the pointer such that it
points to an instance of a CFArray/NSArray.
The problem is you are attempting to pass a pointer to an array into
the method when the method wants the address of the pointer (which
will be made to point at an array).
In other words...
ret = SecKeychainCopySearchList(&anotherSearchList);
If the compiler complains then a cast may be needed...
ret = SecKeychainCopySearchList((CFArrayRef*) &anotherSearchList);
This isn't a Cocoa issue but a C issue...
-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.