Re: Simple CFString ref question (take pity on ObjC dude)
Re: Simple CFString ref question (take pity on ObjC dude)
- Subject: Re: Simple CFString ref question (take pity on ObjC dude)
- From: "Jordan Krushen" <email@hidden>
- Date: Sat, 18 Mar 2006 15:48:43 -0800
On 3/18/06, Steve Cronin <email@hidden> wrote:
> I've got a struct that currently gets populated like so:
> ....
> theParameters.p1 = CFSTR("String1");
> theParameters.p2 = CFSTR("TString2");
>
> What I want to do is change it to something close to:
> theParameters.p3 = [[NSString stringWithFormat:@"%@",newVal]
> cStringUsingEncoding:[NSString defaultCStringEncoding]];
>
> But I get warnings on incompatible pointer type.
>
> I know CFSTR returns a reference to a CFString object, I just can't
> get the syntax right for the NSString
CFString != CString
>From the NSString class description:
NSString is "toll-free bridged" with its Core Foundation counterpart,
CFString. This means that the Core Foundation type is interchangeable
in function or method calls with the bridged Foundation object.
Therefore, in a method where you see an NSString * parameter, you can
pass a CFStringRef, and in a function where you see a CFStringRef
parameter, you can pass an NSString instance (you cast one type to the
other to suppress compiler warnings). This also applies to your
concrete subclasses of NSString. See Interchangeable Data Types for
more information on toll-free bridging.
HTH,
J.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden