RLMSortDescriptor
Objective-C
@interface RLMSortDescriptor : NSObject
Swift
@_nonSendable(_assumed) class RLMSortDescriptor : NSObject, @unchecked Sendable
An RLMSortDescriptor
stores a property name and a sort order for use with
sortedResultsUsingDescriptors:
. It is similar to NSSortDescriptor
, but supports
only the subset of functionality which can be efficiently run by Realm’s query
engine.
RLMSortDescriptor
instances are immutable.
-
The key path which the sort descriptor orders results by.
Declaration
Objective-C
@property (nonatomic, readonly) NSString *_Nonnull keyPath;
Swift
var keyPath: String { get }
-
Whether the descriptor sorts in ascending or descending order.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL ascending;
Swift
var ascending: Bool { get }
-
Returns a new sort descriptor for the given key path and sort direction.
Declaration
Objective-C
+ (nonnull instancetype)sortDescriptorWithKeyPath:(nonnull NSString *)keyPath ascending:(BOOL)ascending;
Swift
convenience init(keyPath: String, ascending: Bool)
-
Returns a copy of the receiver with the sort direction reversed.
Declaration
Objective-C
- (nonnull instancetype)reversedSortDescriptor;
Swift
func reversed() -> Self