Re: Something I don't understand...
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