• 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: A bit stumped....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A bit stumped....


  • Subject: Re: A bit stumped....
  • From: Jeff Binder <email@hidden>
  • Date: Fri, 20 Jul 2001 11:18:05 -0400

You can't compare NSStrings with the == operator. Basically what you're doing there is comparing the addressed stored in the pointers. You can use the isEqualTo: method to compare two strings:

if ([rwdString isEqualTo:readString])
etc.

Also, it's probably a better idea to use indexOfSelectedItem with constants for the item indices instead of titleOfSelectedItem, in case you want to localize the program late.

Jeff Binder

On Friday, July 20, 2001, at 10:49 AM, email@hidden wrote:

Hey all, I'm hoping someone can figure this one out.

I've set up an NSPopupButton in IB. It has three menu items - Read, Write, and Delete.

In PB, I'm using if statements to try to get which item is selected. I've set up one string to be [rwdMenu titleOfSelectedItem] and three other strings that are just set to Read, Write, and Delete. But the if statements won't work! Using NSLog, I can see that the rwdString is either Read, Write, or Delete, depending on which item is selected, but if I do this:

if ( rwdString == readString )
NSLog (@"It's equal to Read");
else if ( rwdString == writeString )
NSLog (@"It's equal to Write");
else if ( rwdString == deleteString )
NSLog (@"It's equal to Delete");
else
NSLog (@"It's not equal to any of those, it's \"%@\"", rwdString);

It ALWAYS tells me it's not equal to any of the strings, though with the last NSLog entry, I see either Read, Write, or Delete. What gives? Is the titleOfSelectedItem in some other encoding than the other strings? Or will this just not work (I hope that's not the answer, it would make things difficult!)?

Thanks for any help,

Mike (aka Darkshadow)
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Follow-Ups:
    • OpenGL and events
      • From: "R. Eranki" <email@hidden>
References: 
 >A bit stumped.... (From: email@hidden)

  • Prev by Date: Re: A bit stumped....
  • Next by Date: Re: Resize corner on NSPanel
  • Previous by thread: Re: A bit stumped....
  • Next by thread: OpenGL and events
  • Index(es):
    • Date
    • Thread