• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: sortedArrayUsingFunction:context: why context is of type void?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: sortedArrayUsingFunction:context: why context is of type void?
      • From: Sherm Pendley <email@hidden>
References: 
 >sortedArrayUsingFunction:context: why context is of type void? (From: Marco Michieli <email@hidden>)

  • Prev by Date: Re: iChat plug-ins?
  • Next by Date: Re: Redirect stderr to NSTextView
  • Previous by thread: Re: sortedArrayUsingFunction:context: why context is of type void?
  • Next by thread: Re: sortedArrayUsingFunction:context: why context is of type void?
  • Index(es):
    • Date
    • Thread