Jonathan.
Jonathan.

Reputation: 55544

custom compare method in objective c

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?

Upvotes: 1

Views: 1048

Answers (1)

bbum
bbum

Reputation: 162712

The comparison is always between otherObject and self.

Upvotes: 4

Related Questions