Re: sortedArrayUsingFunction:context: why context is of type void?
Re: sortedArrayUsingFunction:context: why context is of type void?
- Subject: Re: sortedArrayUsingFunction:context: why context is of type void?
- From: Sherm Pendley <email@hidden>
- Date: Sun, 20 Jun 2004 16:20:20 -0400
On Jun 20, 2004, at 1:04 PM, Marco Michieli wrote:
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?
Use a typecast:
[someObject doSomething: (NSString*)context];
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 kind can be used - that's the point of declaring it as (void*). All
Cocoa knows is that it's a pointer - it doesn't know (or care) what it
points to. So, it's not limited to just object types - C strings,
pointers to structs, etc. can be used.
sherm--
_______________________________________________
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.