Saturday, December 7, 2013

OC in sortUsingSelector method is how to use?

OC in sortUsingSelector method is how to use?
sortUsingSelector: @ selector (compareName :) The @ selector (compareName :) What does it mean? That compareName: What is means? Which gets advice
Reply:
@ Selector () can be considered a method selector, which put your method name.
compareName compare method is a self-realization of it.

Reply:
cited a floor reply:
@ selector () can be considered a method selector, which put your method name.
compareName compare method is a self-realization of it.

Uh ... still do not understand, that the @ selector (compareName) is not referring to the sort by what method? "CompareName compare method is a self-realization of it." What does it mean? Can you give an example ah?
Reply:
For example: If you want a tabview sorted in alphabetic order, but the order tabview current data acquired is confusing, you can sort the data tabview about, and this is one way to own sorting logic implementation. Then you can use sortUsingSelector: @ selector (compareName :), compareName that implement custom sorting method name.
Reply:
- (NSComparisonResult) compareNames: (id) element
{
return [name compare: [element name]];
}

This is a custom comparison method to achieve wow.

Reply:
references, 4th Floor reply:
- (NSComparisonResult) compareNames: (id) element
{
return [name compare: [element name]];
}

This is a custom comparison method to achieve wow.

Is not in use sortUsingSelector: calls @ selector (compareNames :) method n times, according to compareNames: Returns the value to determine the size of the current two elements and sort?
Reply:
reference to the third floor of the reply:
For example: If you want a tabview sorted in alphabetic order, and the current data acquired tabview order is confusing, you can put tabview what sort of data, and this is one way to own sorting logic implementation. Then you can use sortUsingSelector: @ selector (compareName :), compareName that implement custom sorting method name.

For man can not give custom compareName: Method examples? The best that you do not like downstairs, downstairs on the example you have the book
Reply:
If the array element is a string, compareName can write directly compare:

No comments:

Post a Comment