April 2015
Intermediate to advanced
556 pages
17h 47m
English
In the previous section, you specified that the Selector used to sort the Name column should be caseInsensitiveCompare:. The caseInsensitiveCompare: selector corresponds to the method caseInsensitiveCompare(_:) on String. You can use that method programmatically as follows:
let motorsickle: String = "Piaggio"
let motorsigh: String = "Italjet"
let order: NSComparisonResult = motorsickle.caseInsensitiveCompare(motorsigh)
// Would motorsickle come first in the dictionary?
if order == .OrderedAscending {
}
Notice that caseInsensitiveCompare(_:) returns an NSComparisonResult.
The NSComparisonResult describes the how the first string
(motorsickle in this example) is ordered ...
Read now
Unlock full access