Re: Nil items in NSMutableSet
Re: Nil items in NSMutableSet
- Subject: Re: Nil items in NSMutableSet
- From: Jens Alfke <email@hidden>
- Date: Tue, 16 Mar 2010 14:37:44 -0700
On Mar 16, 2010, at 2:18 PM, Alejandro Rodriguez wrote:
[ob isEqual:@"hello"]; //returns YES
[@"hello" isEqual:ob]; //returns NO
That may very well be the problem... now... I have no idea on how I
will make the second test return YES.
You can't do that in Objective-C, unfortunately. It would require
splicing into NSString's implementation of -isEqual: and adding your
own test before the existing one. (You could probably do it by messing
with the runtime to replace the method, but that would be very nasty.)
This basically allows me to do something like [messageSet
member:@"123"] and return the object with ID 123 or [memberSet
member:messageObject] and have the same result.
It might be convenient to do that, but there isn't a clean way to
implement it. You'll need to think of another way to do what you want
to do. One possibility is to use an NSDictionary mapping identifiers
to your objects.
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden