I have a PHAssetCollection (an album), which I have in my app. On viewDidLoad(), my code checks to see if there is a picture already in the album, and if so, it adds the pre-existing picture to the PHAssetCollecton. However, I NEVER want to add pre-existing pictures in the PHAssetCollection. I always want my assetCollection to be fresh, without any picture(s) or data.
How do I set self.assetCollection to be a brand new AssetCollection with no picture(s) or data? Deleting that line of code causes my app to crash...
code in viewDidLoad()
//Check if the folder exists, if not, create it
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "title = %@", albumName)
let collection:PHFetchResult = PHAssetCollection.fetchAssetCollectionsWithType(.Album, subtype: .Any, options: fetchOptions)
if let first_Obj:AnyObject = collection.firstObject{
//Album already exists, and has pictures.
self.albumFound = true
//Here is my issue. I want to set self.assetCollection to a brand new PHAssetCollection with NO data... brand new
self.assetCollection = first_Obj as! PHAssetCollection
There is also this code in viewDidAppear, I am unsure if this is of any use, but contains self.assetCollection so I added it:
self.photosAsset = PHAsset.fetchAssetsInAssetCollection(self.assetCollection, options: nil)