Platforms to show: All Mac Windows Linux Cross-Platform
NSSortDescriptorMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | iCloud | MBS Main Plugin | 11.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
An instance of NSSortDescriptor describes a basis for ordering objects by specifying the property to use to compare the objects, the method to use to compare the properties, and whether the comparison should be ascending or descending. Instances of NSSortDescriptor are immutable.
You construct an instance of NSSortDescriptor by specifying the key path of the property to be compared, the order of the sort (ascending or descending), and (optionally) a selector to use to perform the comparison. The three-argument constructor allows you to specify other comparison selectors such as caseInsensitiveCompare: and localizedCompare:. Sorting raises an exception if the objects to be sorted do not respond to the sort descriptor's comparison selector.
Note: Many of the descriptions of NSSortDescriptor methods refer to "property key". This, briefly, is a string (key) that identifies a property (an attribute or relationship) of an object. You can find a discussion of this terminology in "Object Modeling" in Cocoa Fundamentals Guide and in Key-Value Coding Programming Guide.
There are a number of situations in which you can use sort descriptors, for example:
- To sort an array (an instance of NSArray or NSMutableArray—see sortedArrayUsingDescriptors and sortUsingDescriptors)
- To directly compare two objects (see compareObject method)
- To specify how the elements in a table view should be arranged (see sortDescriptors)
- To specify how the elements managed by an array controller should be arranged (see sortDescriptors)
- If you are using Core Data, to specify the ordering of objects returned from a fetch request (see sortDescriptors)
- event Comparator(obj1 as Variant, obj2 as Variant) as Integer
- 4 properties
- 4 methods
- method compareObject(obj1 as variant, obj2 as variant) as Integer
- method Constructor(key as string, ascending as boolean)
- method Constructor(key as string, ascending as boolean, SelectorName as String)
- method reversedSortDescriptor as NSSortDescriptorMBS
- 8 shared methods
- shared method sortDescriptorWithKey(key as string, ascending as boolean) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyComparator(key as string, ascending as boolean, Comparator as NSComparatorDelegateMBS, tag as Variant = nil) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyWithCaseInsensitiveCompare(key as string, ascending as boolean) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyWithCompare(key as string, ascending as boolean) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyWithCompare(key as string, ascending as boolean, Options as Integer) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyWithLocalizedCaseInsensitiveCompare(key as string, ascending as boolean) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyWithLocalizedCompare(key as string, ascending as boolean) as NSSortDescriptorMBS
- shared method sortDescriptorWithKeyWithSelector(key as string, ascending as boolean, SelectorName as String) as NSSortDescriptorMBS
- delegate NSComparatorDelegateMBS(obj1 as Variant, obj2 as Variant, tag as variant) as Integer
Sub classes:
Some methods using this class:
- CKQueryMBS.sortDescriptors as NSSortDescriptorMBS()
- KeyValueCodingMBS.sortedArrayUsingDescriptor(values() as KeyValueCodingMBS, sortDescriptor as NSSortDescriptorMBS) as KeyValueCodingMBS()
- NSMetadataQueryMBS.setSortDescriptor(sortDescriptor as NSSortDescriptorMBS)
- NSMetadataQueryMBS.setSortDescriptors(sortDescriptors() as NSSortDescriptorMBS)
- NSMetadataQueryMBS.sortDescriptors as NSSortDescriptorMBS()
- NSOutlineViewItemMBS.sortedArrayUsingDescriptors(values() as NSOutlineViewItemMBS, sortDescriptor() as NSSortDescriptorMBS) as NSOutlineViewItemMBS()
- NSTableViewMBS.setSortDescriptor(sortDescriptor as NSSortDescriptorMBS)
- NSTableViewMBS.setSortDescriptors(sortDescriptors() as NSSortDescriptorMBS)
- NSTableViewMBS.sortDescriptors as NSSortDescriptorMBS()
- PHFetchOptionsMBS.setSortDescriptors(sortDescriptors() as NSSortDescriptorMBS)
Some properties using for this class:
- NSTableColumnMBS.sortDescriptorPrototype as NSSortDescriptorMBS
Some events using this class:
- DesktopNSOutlineControlMBS.sortDescriptorsDidChange(oldDescriptors() as NSSortDescriptorMBS)
- DesktopNSTableControlMBS.sortDescriptorsDidChange(oldDescriptors() as NSSortDescriptorMBS)
- NSOutlineControlMBS.sortDescriptorsDidChange(oldDescriptors() as NSSortDescriptorMBS)
- NSTableControlMBS.sortDescriptorsDidChange(oldDescriptors() as NSSortDescriptorMBS)
- NSTableDataSourceMBS.sortDescriptorsDidChange(oldDescriptors() as NSSortDescriptorMBS)
Some examples using this class:
- /MacCloud/NSMetadataquery test
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Flat Only/ListBoxTV Database with DataSource
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Flat Only/ListBoxTV Simple Demo with DataSource
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Flat Only/ListBoxTV TableView
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Flat Only/ListboxTV with ContainerControl Cells
- /MacControls/Listbox and TableView Demos/ListboxTV drop-in/Hierarchical & Flat/ListBoxTV OutlineView
Blog Entries
- MBS Xojo Plugins, version 17.1pr5
- MBS Xojo / Real Studio Plugins, version 14.2pr10
- More notes
- MBS Real Studio Plugins, version 11.3pr10
Release notes
- Version 17.1
- Added NSSortDescriptorMBS.compareObject.
The items on this page are in the following plugins: MBS Mac64bit Plugin, MBS Main Plugin.
NSSliderTouchBarItemMBS - NSSoundDelegateMBS