Re: Cannot get indexOfObject to work
Re: Cannot get indexOfObject to work
- Subject: Re: Cannot get indexOfObject to work
- From: p3consulting <email@hidden>
- Date: Fri, 19 Mar 2004 22:07:19 +0100
The problem is that the object @"caption" is NOT an object of your
custom class...
So if indexOfObject sends an isEqual message to it, it is the isEqual
of NSString class that is executed not yours !
Pascal Pochet
email@hidden
Le 19 Mar 2004, ` 20:16, Bartlomiej Cichosz a icrit :
I have a custom class (let's call it CL) derived from NSObject, which
implements isEqual: - currently, for debugging purposes it is defined
as:
- (BOOL)isEqual:(id)anObject {
NSLog(@"isEqual called");
return YES;
}
I also have an NSMutableArray containing number of CL objects. I am
trying to use indexOfObject to locate particular object, but I get
NSNotFound regardless of what I am searching for. My code looks as
follows:
if([[a objectAtIndex:6] isEqual:@"caption"]) {
NSLog(@"Yes, they are the same");
}
i=[a indexOfObject:@"caption"];
if(i==NSNotFound) {
NSLog(@"Not found");
}
Variable a is the NSMutableArray I mentioned. The output I get is:
2004-03-19 13:57:29.435 App[8533] isEqual called
2004-03-19 13:57:29.435 App[8533] Yes, they are the same
2004-03-19 13:57:29.435 App[8533] Not found
_______________________________________________
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.