• 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: Using NSString in a switch() statement (newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Restricting an NSSplitView when Resizing a Window
  • Next by Date: Re: formatting NSDate
  • Previous by thread: Re: Some Questions
  • Next by thread: How to scroll an view using the hand metaphor?
  • Index(es):
    • Date
    • Thread