Re: Usage of NSSortDescriptor
Re: Usage of NSSortDescriptor
- Subject: Re: Usage of NSSortDescriptor
- From: Ali Ozer <email@hidden>
- Date: Mon, 24 Nov 2003 19:13:12 -0800
Note that the selector is the selector to be applied to objects
identified by the key. Given this, sortByFilenames doesn't sound like
it's correct. If FILENAME is the key, assuming this key is a string,
then you would pass the selector NSSelector("compare", new Class[]
{NSObject.class})), because you will be sending compare: methods to
instances of NSString. (Using NSObject instead of NSString, because
NSString isn't known to Java.)
Here's a simple example which sorts the array of dictionaries based on
the values of their "name" key:
NSMutableArray array = new NSMutableArray();
array.addObject(new NSDictionary("Bob", "name"));
array.addObject(new NSDictionary("alf", "name"));
array.addObject(new NSDictionary("Abe", "name"));
array.addObject(new NSDictionary("Zoe", "name"));
NSSystem.log("" + array);
NSSortDescriptor sortDesc = new NSSortDescriptor("name", true, new
NSSelector("localizedCaseInsensitiveCompare", new Class[]
{NSObject.class}));
array.sortUsingDescriptors(new NSArray(sortDesc));
NSSystem.log("" + array);
Ali
Begin forwarded message:
From: David Kocher <email@hidden>
Date: November 24, 2003 16:29:12 PST
To: email@hidden
Subject: Usage of NSSortDescriptor
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I would like to make use of the new NSSortDescriptor class. However I
am wondering what arguments I should declare in the selector method.
My sorting method never gets called.
this.myTableView.tableColumnWithIdentifier("FILENAME").setSortDescripto
rPrototype(
new NSSortDescriptor(
"FILENAME",
true,
new NSSelector("sortByFilenames", new Class[]
{Object.class}))
);
Thanks for the help. (btw: this is cocoa-java)
- --David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)
iD8DBQE/wqJZdBH4SdTFvT4RAnhGAJ0dooVJe3NS581QBcOPprXjckZ5oQCfQtBm
KjfxD7NworiKhQXqRmFLKhY=
=VMcT
-----END PGP SIGNATURE-----
_______________________________________________
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.
_______________________________________________
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.