• 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: Working with Strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Working with Strings


  • Subject: Re: Working with Strings
  • From: Brendan Younger <email@hidden>
  • Date: Sun, 15 Jul 2001 11:01:04 -0500

1. Can I compare the return value of NSString characterAtIndex: with a normal character constant? i.e. will

if( [ myString characterAtIndex:0 ] == 'a' ) ...

Yes, you can do this. You may also want to look into NSScanner. It very well may replace much of your own code.

2. What's the easiest way to append a single character to an NSString? For constants, I'm using appendString: @"<character". What's the simplest way to do this with variables?

Keep doing what you're doing with constants but create the string dynamically. Check out the convenience constructors in NSString, -stringWithCString: and -stringWithCharacters:length:

Brendan Younger


References: 
 >Working with Strings (From: Ben Jansen <email@hidden>)

  • Prev by Date: Re: NSAlertPanel.beginAlertSheet
  • Next by Date: Re: NSAlertPanel.beginAlertSheet
  • Previous by thread: Working with Strings
  • Next by thread: Re: Working with Strings
  • Index(es):
    • Date
    • Thread