Re: Switch/case with NSString?
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