mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 02:01:03 +00:00
Added missing Mac OS X 10.6 methods related to NSSortDescriptor
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37689 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
feddbf6a1b
commit
2dd421fbff
3 changed files with 63 additions and 0 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2014-02-14 Quentin Mathe <quentin.mathe@gmail.com>
|
||||||
|
|
||||||
|
* Headers/Foundation/NSSortDescriptor.h
|
||||||
|
* Source/Foundation/NSSortDescriptor.m
|
||||||
|
(+sortDescriptorWithKey:ascending:selector:,
|
||||||
|
+sortDescriptorWithKey:ascending,
|
||||||
|
-[NSSet sortedArrayUsingDescriptors:]): Added missing Mac OS X 10.6
|
||||||
|
methods.
|
||||||
|
|
||||||
2014-02-13 Richard Frith-Macdonald <rfm@gnu.org>
|
2014-02-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSFormat.m: Fix to cope with cases where a format specifies
|
* Source/GSFormat.m: Fix to cope with cases where a format specifies
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSSet.h>
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -74,6 +75,25 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
- (NSComparisonResult) compareObject: (id)object1 toObject: (id)object2;
|
- (NSComparisonResult) compareObject: (id)object1 toObject: (id)object2;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||||
|
/** Returns an autoreleased sort descriptor for comparisons using the
|
||||||
|
* 'compare:' selector and the specified key and ordering.
|
||||||
|
*
|
||||||
|
* See also -initWithKey:ascending:.
|
||||||
|
*/
|
||||||
|
+ (id) sortDescriptorWithKey: (NSString *)aKey ascending: (BOOL)ascending;
|
||||||
|
|
||||||
|
/** Returns an autoreleased sort descriptor initialized to perform comparisons
|
||||||
|
* in the specified order using aSelector to compare the property aKey of each
|
||||||
|
* object.
|
||||||
|
*
|
||||||
|
* See also -initWithKey:ascending:selector:.
|
||||||
|
*/
|
||||||
|
+ (id) sortDescriptorWithKey: (NSString *)aKey
|
||||||
|
ascending: (BOOL)ascending
|
||||||
|
selector: (SEL)aSelector;
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Initialises the receiver for comparisons using the 'compare:' selector
|
/** Initialises the receiver for comparisons using the 'compare:' selector
|
||||||
* and the specified key and ordering.
|
* and the specified key and ordering.
|
||||||
*/
|
*/
|
||||||
|
@ -129,6 +149,16 @@ extern "C" {
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6,GS_API_LATEST)
|
||||||
|
@interface NSSet (NSSortDescriptorSorting)
|
||||||
|
/**
|
||||||
|
* Produces a sorted array from using the mechanism described for
|
||||||
|
* [NSMutableArray-sortUsingDescriptors:]
|
||||||
|
*/
|
||||||
|
- (NSArray *) sortedArrayUsingDescriptors: (NSArray *)sortDescriptors;
|
||||||
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -121,6 +121,20 @@ static BOOL initialized = NO;
|
||||||
return _ascending + GSPrivateHash(0, sel, strlen(sel)) + [_key hash];
|
return _ascending + GSPrivateHash(0, sel, strlen(sel)) + [_key hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (id) sortDescriptorWithKey: (NSString *)aKey ascending: (BOOL)ascending
|
||||||
|
{
|
||||||
|
return AUTORELEASE([[self alloc] initWithKey: aKey ascending: ascending]);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) sortDescriptorWithKey: (NSString *)aKey
|
||||||
|
ascending: (BOOL)ascending
|
||||||
|
selector: (SEL)aSelector
|
||||||
|
{
|
||||||
|
return AUTORELEASE([[self alloc] initWithKey: aKey
|
||||||
|
ascending: ascending
|
||||||
|
selector: aSelector]);
|
||||||
|
}
|
||||||
|
|
||||||
- (id) initWithKey: (NSString *) key ascending: (BOOL) ascending
|
- (id) initWithKey: (NSString *) key ascending: (BOOL) ascending
|
||||||
{
|
{
|
||||||
return [self initWithKey: key ascending: ascending selector: NULL];
|
return [self initWithKey: key ascending: ascending selector: NULL];
|
||||||
|
@ -449,3 +463,13 @@ SortRange(id *objects, NSRange range, id *descriptors,
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@implementation NSSet (NSSortDescriptorSorting)
|
||||||
|
|
||||||
|
- (NSArray *) sortedArrayUsingDescriptors: (NSArray *)sortDescriptors
|
||||||
|
{
|
||||||
|
return [[self allObjects] sortedArrayUsingDescriptors: sortDescriptors];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue