• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString equivalent of CFSTR macro?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSString equivalent of CFSTR macro? (From: Rick Mann <email@hidden>)
 >Re: NSString equivalent of CFSTR macro? (From: Ben Kennedy <email@hidden>)
 >Re: NSString equivalent of CFSTR macro? (From: Greg Parker <email@hidden>)
 >Re: NSString equivalent of CFSTR macro? (From: Rick Mann <email@hidden>)
 >Re: NSString equivalent of CFSTR macro? (From: Greg Parker <email@hidden>)
 >Re: NSString equivalent of CFSTR macro? (From: Rick Mann <email@hidden>)
 >Re: NSString equivalent of CFSTR macro? (From: Greg Parker <email@hidden>)

  • Prev by Date: Re: NSString equivalent of CFSTR macro?
  • Next by Date: Zooming Breaks Focus-ring Architecture (10.13.1)
  • Previous by thread: Re: NSString equivalent of CFSTR macro?
  • Next by thread: Re: NSString equivalent of CFSTR macro?
  • Index(es):
    • Date
    • Thread