Re: NSString equivalent of CFSTR macro?
Re: NSString equivalent of CFSTR macro?
- Subject: Re: NSString equivalent of CFSTR macro?
- From: Rick Mann <email@hidden>
- Date: Mon, 4 Dec 2017 16:23:46 -0800
> On Dec 4, 2017, at 16:14 , Greg Parker <email@hidden> wrote:
>
>
>> 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.
Yeah, I figured as much. In this case, that's okay. I was just trying to
declutter the call site. Thanks!
--
Rick Mann
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