• 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: Switch/case with NSString?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switch/case with NSString?


  • Subject: Re: Switch/case with NSString?
  • From: Andrew Farmer <email@hidden>
  • Date: Wed, 3 Jan 2007 03:00:14 -0800

On 03 Jan 07, at 02:32, d2kagw wrote:
Hi there,

Anyone know if its possible to do a switch statement with a NSString?

No. Switch statements only work on values that can be treated as integers.


or if there's something similar that you could use as a replacement?

In order of increasing complexity:

* Chain of if statements with string comparisons

* Tree of if statements testing character-by-character

* Switch on the string's hash value

(Note that this is also in order of increasing incomprehensibility for future maintainers of your code.)
_______________________________________________


Cocoa-dev mailing list (email@hidden)

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: 
 >more than one attribute in tableview cell (From: "email@hidden" <email@hidden>)
 >Re: more than one attribute in tableview cell (From: Volker Runkel <email@hidden>)
 >Switch/case with NSString? (From: d2kagw <email@hidden>)

  • Prev by Date: Switch/case with NSString?
  • Next by Date: Re: Switch/case with NSString?
  • Previous by thread: Switch/case with NSString?
  • Next by thread: Re: Switch/case with NSString?
  • Index(es):
    • Date
    • Thread