이신우
이신우

Reputation: 39

Why NSSortDescriptor array is put into sortDescriptors?

let dateSort = NSSortDescriptor(key: "created", ascending: false)
fetchRequest.sortDescriptors = [dateSort]

I think [dateSort] is array transformation of NSSortDescriptor object. (If not, please tell me what it is.) So why does sortDescriptors take the array of NSSortDescriptor, not just single NSSortDescriptor?

Upvotes: 0

Views: 100

Answers (2)

rmaddy
rmaddy

Reputation: 318884

You pass an array of sort descriptors because you can provide multiple levels of sorts. If the first level compares equal, the next level is checked. This continues for as many sort levels as you specify.

Upvotes: 2

Todanley
Todanley

Reputation: 508

It is an array transformation of NSSortDescriptor object. It's trying to allow you to sort using multiple criteria.

Upvotes: 0

Related Questions