Unsupported sort descriptor in fetch options

It seems that I can not get a fetch result sorted by localIdentifier. Here is the code:

let sortDescriptor = NSSortDescriptor(key: "localIdentifier", ascending: true)
let options = PHFetchOptions()
options.sortDescriptors = [sortDescriptor]
let albums = PHCollection.fetchTopLevelUserCollections(with: options)
print(albums.count)

I've got this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported sort descriptor in fetch options: (localIdentifier, ascending, compare:)'

However in Apple doc, localIdentifier can be used as key.

I've tried with PHAssetCollection.fetchAssetCollections, same problem, unable to use localIdentifier as key.

Replies

I'v met the same problem. Have you solved it now

<PHAssetCollection> class do not support 'creationDate' key