I've created three PHCollections within my app. In a different part of my app, I'm attempting to fetch them and display them in a table view. I can get all of the user created libraries by using the following code
let topLevelUserCollections: PHFetchResult = PHCollectionList.fetchTopLevelUserCollectionsWithOptions(nil)
self.collectionsFetchResults = [topLevelUserCollections];
self.collectionsLocalizedTitles = ["My Clips"];
PHPhotoLibrary.sharedPhotoLibrary().registerChangeObserver(self) //With this you need to conform to PHPhotoLibraryChangeObserver
but how can I fetch only the asset collection I want? Also, I only want video and not images, is there a way to fetch only results with videos assests?
You are calling
PHCollectionList.fetchTopLevelUserCollectionsWithOptions
with a parameter of nil. But that nil is the PHFetchOptions. Those PHFetchOptions are exactly how you make this sort of specification.In particular, if you created these collections yourself, you have their
localIdentifier
values. That is exactly what you would specify in the PHFetchOptionspredicate
to pull out those collections. You could also do it bylocalizedTitle
and so on.