• 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: Something I don't understand...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Something I don't understand...


  • Subject: Re: Something I don't understand...
  • From: Chuck Pisula <email@hidden>
  • Date: Tue, 8 May 2001 08:38:59 -0700

ObjC does not have operator overloading for this sort of thing. You should compare by checking if ([someString isEqualToString: @"someOtherString"]). Also, I would recommend checking against the -itemIdentifier of you item instead of the -label since the label is something that should be localized, but the identifier is not.

-chuck


On Tuesday, May 8, 2001, at 07:27 AM, rsharp wrote:

On Tue, 8 May 2001, Matt Ridley wrote:

One of the items does indeed have the label "Sample", but when I
click it I never get the beep. The method is definitely firing,
and I can get the label of the item (when I NSLog it, it shows
up as "Sample", just as I'd expect). Is there something very
basic I'm not understanding about how to compare the two strings?

- (void)toolbaritemclicked:(NSToolbarItem*)item {
if ([item label] == @"Sample")
NSBeep();
}

What happens if you use the compare method of NSString rather than
operator == ?

I know that in Java, == will actually do an object equivalency test rather
than an object's contents equivalency test.

Of course, I may be completely wrong...I've only been doing Obj-C for 2
days now.

Rick Sharp
Instant Interactive(tm)
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Prev by Date: Re: And another thing I don't quite understand... ;-)
  • Next by Date: Re: And another thing I don't quite understand... ;-)
  • Previous by thread: Re: Something I don't understand...
  • Next by thread: And another thing I don't quite understand... ;-)
  • Index(es):
    • Date
    • Thread