2 Replies
      Latest reply on Mar 9, 2020 7:57 AM by sxxjxxhxxn
      nouatzi Level 1 Level 1 (0 points)

        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.