Re: Using NSString in a switch() statement (newbie)
Re: Using NSString in a switch() statement (newbie)
- Subject: Re: Using NSString in a switch() statement (newbie)
- From: Hisaoki Nishida <email@hidden>
- Date: Mon, 17 Feb 2003 19:28:09 -0500
Doh, I forgot about enums.
Thanks, I'll use that.
(What a newbie post this was)
-yuki
On Monday, February 17, 2003, at 07:22 PM, Rodney Dyer wrote:
Yuki,
Define an enum in your chess piece class to determine its identity.
Then in any of these type of situations you could go:
switch ( [self type]) {
case ROOK:
[self doSomeRookStuff];
break;
etc...
}
This way you've reduced the overhead of your class's identification to
an integer taken from the enum. In fact, you can place much of this
functionality in the chessPiece main class.
Let me know if I can provide any further information
Ciao,
Rodney
On Monday, Feb 17, 2003, at 17:13 America/Chicago, Hisaoki Nishida
wrote:
Hi,
I have an NSString that I want to use as a determinant for a switch()
statement.
I'm not exactly sure how I would do this.
switch([NSString cString])
{
case CONSTANT_str1:
// ...
break;
// etc.
}
Would this be a good approach?
Or can I use NSString itself somehow, as the determinant?
Thank you,
-yuki
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev
// Hisaoki "Yuki" Nishida
// <email@hidden>
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.