• 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: C string constant->NSString constant without defining twice?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C string constant->NSString constant without defining twice?


  • Subject: Re: C string constant->NSString constant without defining twice?
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Tue, 28 Apr 2009 10:51:10 -0500

On Tue, Apr 28, 2009 at 10:18 AM, Erik Buck <email@hidden> wrote:
> I haven't tried, but I don't think the following works because of the way the pre-processor inserts spaces:
> #define kConstCString "This is a const c string"
> #define kConstNSString @kConstCString

Well, if that doesn't work (and I didn't test it) this should:

#define kConstCString "This is a const c string"
#define kConstNSString ((NSString*)CFSTR( kConstCString ))

> Don't hard code paths!  Use NSHomeDirectory() or NSTemporaryDirectory() or
> NSSearchPathForDirectoriesInDomains().

Not only that, but hardcoding filenames in tmp directories is
generally considered a security bug. You should be using mktemp or one
of its ilk. Not sure if there's a Cocoa API for that.
_______________________________________________

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

  • Follow-Ups:
    • Re: C string constant->NSString constant without defining twice?
      • From: Graham Lee <email@hidden>
References: 
 >Re: C string constant->NSString constant without defining twice? (From: Erik Buck <email@hidden>)

  • Prev by Date: Re: Why is NSString->FSRef so hard?
  • Next by Date: Re: Second frontmost app?
  • Previous by thread: Re: C string constant->NSString constant without defining twice?
  • Next by thread: Re: C string constant->NSString constant without defining twice?
  • Index(es):
    • Date
    • Thread