• 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: stringWithFormat / Rendering Text (iOS)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stringWithFormat / Rendering Text (iOS)


  • Subject: Re: stringWithFormat / Rendering Text (iOS)
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 24 May 2012 10:52:47 -0500

On May 24, 2012, at 2:49 AM, Jason Teagle wrote:

> First, a quick question about +stringWithFormat: If I want to have a literal string as one of the parameters to the format, which is correct / best:
>
> NSString *textToDraw = [NSString stringWithFormat: @"%s",
> 	"my string"];
>
> or
>
> NSString *textToDraw = [NSString stringWithFormat: @"%@",
> 	@"my string"];

Given what's been said elsewhere about these being cut-down example snippets and not anything real...  Never use the "%s" format specifier.  It interprets the C string argument in a completely unreliable encoding.  If the argument contains or could contain any non-ASCII characters, you're likely to get a nasty surprise.  Worse, the nasty surprise may not show up until your code is run on a system set to a language/locale other than your usual one.

Regards,
Ken


_______________________________________________

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: 
 >applicationDidHide - Not Getting Triggered? (From: Jason Teagle <email@hidden>)
 >Re: applicationDidHide - Not Getting Triggered? (From: Ken Thomases <email@hidden>)
 >Re: applicationDidHide - Not Getting Triggered? (From: Jason Teagle <email@hidden>)
 >Re: applicationDidHide - Not Getting Triggered? (From: Ken Thomases <email@hidden>)
 >stringWithFormat / Rendering Text (iOS) (From: Jason Teagle <email@hidden>)

  • Prev by Date: Re: NSWindowController subclasses, and retain cycles
  • Next by Date: Re: Multiple Inheritance
  • Previous by thread: Re: stringWithFormat / Rendering Text (iOS)
  • Next by thread: In a modal pickle
  • Index(es):
    • Date
    • Thread