• 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: and other variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sortedArrayUsingFunction:context: and other variables


  • Subject: Re: sortedArrayUsingFunction:context: and other variables
  • From: Boyd Collier <email@hidden>
  • Date: Mon, 6 Aug 2007 10:23:02 -0700

Maybe I'm overlooking something very obvious, but why don't you simply change your function to something like this:

int orderWordsByUseInDictionary (NSDictionary *indexedWordsWithCounts, id tWord1, id tWord2, void * reverse )

and then make use of indexedWordsWithCounts within its body?

Boyd


On Aug 5, 2007, at 2:03 PM, Aaron Wallis wrote:

I'm trying to sort an array using the sortedArrayUsingFunction:context:
method, however, the function i'm writing needs to be aware of other variables around it.


int orderWordsByUseInDictionary ( id tWord1, id tWord2, void * reverse )
{
int word1Count = [[indexedWordsWithCounts objectForKey:tWord1] intValue];
int word2Count = [[indexedWordsWithCounts objectForKey:tWord2] intValue];


	if ( word1Count > word2Count )
	{
		return NSOrderedAscending;
	}
	else if ( word1Count < word2Count )
	{
		return NSOrderedDescending;
	}
	else
	{
		return NSOrderedSame;
	}
}

when it comes to compiling, I get the error "'indexedWordsWithCounts' undeclared (first use in this function)" cause its a parameter of the object and the function can't seem to access it.

Is there anyway of making the function aware of the dictionary? since it requires the dictionaries data to properly sort the array.

Cheers

________________________/Az.________

Aaron Wallis
http://isnot.tv


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40sunstroke.sdsu.edu


This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: sortedArrayUsingFunction:context: and other variables
      • From: Uli Kusterer <email@hidden>
References: 
 >sortedArrayUsingFunction:context: and other variables (From: Aaron Wallis <email@hidden>)

  • Prev by Date: Re: Is SearchKit's binary index Universal?
  • Next by Date: Turning off sorting for one column of an NStableView
  • Previous by thread: Re: sortedArrayUsingFunction:context: and other variables
  • Next by thread: Re: sortedArrayUsingFunction:context: and other variables
  • Index(es):
    • Date
    • Thread