sortedArrayUsingFunction:context: why context is of type void?
sortedArrayUsingFunction:context: why context is of type void?
- Subject: sortedArrayUsingFunction:context: why context is of type void?
- From: Marco Michieli <email@hidden>
- Date: Sun, 20 Jun 2004 19:04:05 +0200
I'm using the following NSArray method to sort a TableView:
- (NSArray *) sortedArrayUsingFunction: (int (*)(id, id, void
*))comparator
context: (void *) context
Documentation says:
"Each time the comparison function is called, it's passed context as
its third argument. This allows the comparison to be based on some
outside parameter, such as whether character sorting is case-sensitive
or case-insensitive."
When one of the Column Headers of tableView is clicked I sort the
tableView using the tableColumn identifier as outside parameter:
- (void)tableView:(NSTableView*)tableView
didClickTableColumn:(NSTableColumn *)tableColumn
{
// Highlight tableColumn and set the indicator image
(...)
// Sort tableViewArray and updateUI
[[self tableViewArray] sortUsingFunction:mySortFunction
context:[tableColumn identifier]];
[self updateUI];
}
It works just fine, but because "context" is defined as void
int mySortFunction(id item1, id item2, void *context)
and I actually pass an NSString (identifier) to control the comparison
function behaviour, I got always a boring warning message when building
my application;
How can avoid that? What kind of outside parameter is supposed to be
used? I expected context to be of type id, but it's actally of type
void: why?
Any explanation would be greatly appreciated.
Thanks
Marco
_______________________________________________
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.