• 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: (newbie question) Putting special characters in NSStrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (newbie question) Putting special characters in NSStrings


  • Subject: Re: (newbie question) Putting special characters in NSStrings
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Fri, 18 Mar 2005 22:22:49 +0100

At 11:33 Uhr -0800 18.03.2005, Ben Borofka wrote:
I have a bunch of special characters I need to put in NSStrings and
NSArrays of NSStrings:

" ! @ # $ % ^ *

I've been just using, for example, [[NSString alloc ]
initWithString:@"!"] to create the string but I don't think they are
working for all those special characters. What's the best way to put
those into an NSString? I can't find any simple, easy examples.

Define "special characters". The ones above should just work, but if you're trying anything outside ASCII range, you can't do that (ObjC only supports ASCII in its source files). To get other characters, you'll have to use a Localizable.strings file or a .plist file to load the strings from, then it'll Just Work(tm).


Oh, and BTW, you don't need to alloc/initWithString if the string you're starting with already is abn @"something" string constant. The following two lines are equivalent:

foo = [[NSString alloc ] initWithString: @"!"];
foo = [@"!" retain];

And if you don't want to retain it anyway, you could even do

foo = @"!";

instead of

foo = [[[NSString alloc ] initWithString: @"!"] autorelease];

in most cases. String constants are full-blown objects.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
       "The Witnesses of TeachText are everywhere..."
                   http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >(newbie question) Putting special characters in NSStrings (From: Ben Borofka <email@hidden>)

  • Prev by Date: leak in NSInvocation when NOT using zero link ?
  • Next by Date: Re: (newbie question) Putting special characters in NSStrings
  • Previous by thread: (newbie question) Putting special characters in NSStrings
  • Next by thread: Re: (newbie question) Putting special characters in NSStrings
  • Index(es):
    • Date
    • Thread