views:

105

answers:

1

I'm trying to use a custom compare method (for use with sortedArrayUsingSelector:) and on another website I got that the format is:

-(NSComparisonResult) orderByName:(id)otherobject {

That's all very well and good, except how do I compare the otherObject to anything as there's only one thing passed to the method?

Like how does the NSString method of compare: compare 2 strings when only one string is passed?

+3  A: 

The comparison is always between otherObject and self.

bbum
To clarify: `[someString compare:@"bar"]` would compare `someString` to the string liertal `@"bar"`. The object you are missing is the object you call the compare method on. So, within the method `self` is compared to `otherObject`.
Squeegy