iOS使用sortDescriptor设置为localIdentifier来获取集合

时间:2017-03-09 09:10:28

标签: ios nssortdescriptor photosframework photokit

似乎我无法获得由localIdentifier排序的获取结果。这是代码:

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

我有这个错误:

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

但是在Apple doc中,localIdentifier可以用作密钥。

0 个答案:

没有答案