From: <ho...@us...> - 2007-07-06 23:08:18
|
Revision: 2434 http://skim-app.svn.sourceforge.net/skim-app/?rev=2434&view=rev Author: hofman Date: 2007-07-06 16:08:07 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Add some convenient sorting methods for templating. Modified Paths: -------------- trunk/NSArray_SKExtensions.h trunk/NSArray_SKExtensions.m Modified: trunk/NSArray_SKExtensions.h =================================================================== --- trunk/NSArray_SKExtensions.h 2007-07-06 18:42:01 UTC (rev 2433) +++ trunk/NSArray_SKExtensions.h 2007-07-06 23:08:07 UTC (rev 2434) @@ -42,6 +42,9 @@ @interface NSArray (SKExtensions) - (NSArray *)arraySortedByPageIndex; - (NSArray *)arraySortedByBounds; +- (NSArray *)arraySortedByPageIndexAndBounds; - (NSArray *)arraySortedByType; - (NSArray *)arraySortedByContents; +- (NSArray *)arraySortedByTypeAndContents; +- (NSArray *)arraySortedByTypeAndPageIndex; @end Modified: trunk/NSArray_SKExtensions.m =================================================================== --- trunk/NSArray_SKExtensions.m 2007-07-06 18:42:01 UTC (rev 2433) +++ trunk/NSArray_SKExtensions.m 2007-07-06 23:08:07 UTC (rev 2434) @@ -50,6 +50,10 @@ return [self sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"bounds" ascending:YES selector:@selector(boundsCompare:)] autorelease]]]; } +- (NSArray *)arraySortedByPageIndexAndBounds { + return [self sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"pageIndex" ascending:YES selector:@selector(compare:)] autorelease], [[[NSSortDescriptor alloc] initWithKey:@"bounds" ascending:YES selector:@selector(boundsCompare:)] autorelease], nil]]; +} + - (NSArray *)arraySortedByType { return [self sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"noteType" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease]]]; } @@ -58,4 +62,12 @@ return [self sortedArrayUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease]]]; } +- (NSArray *)arraySortedByTypeAndContents { + return [self sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"noteType" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], [[[NSSortDescriptor alloc] initWithKey:@"contents" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], nil]]; +} + +- (NSArray *)arraySortedByTypeAndPageIndex { + return [self sortedArrayUsingDescriptors:[NSArray arrayWithObjects:[[[NSSortDescriptor alloc] initWithKey:@"noteType" ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease], [[[NSSortDescriptor alloc] initWithKey:@"pageIndex" ascending:YES selector:@selector(compare:)] autorelease], nil]]; +} + @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |