Re: NSString equivalent of CFSTR macro?
Re: NSString equivalent of CFSTR macro?
- Subject: Re: NSString equivalent of CFSTR macro?
- From: Greg Parker <email@hidden>
- Date: Mon, 04 Dec 2017 16:14:49 -0800
> On Dec 4, 2017, at 3:22 PM, Rick Mann <email@hidden> wrote:
>
> Ugh...been doing too much Swift (j/k). The right answer to this question is:
>
> @(kSomeCStringConstant)
>
> This works whether it's a #define or a static const char* const.
The downsides are:
1. If the library requires that you use the actual address stored in string
variable kSomeCStringConstant then it may fail because @(kSomeCStringConstant)
may create a second object at a different address.
2. The compiler is not currently smart enough to optimize
@(kSomeCStringConstant) into a constant string object, so it may allocate a new
autoreleased string object every time it runs that line.
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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