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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com