Avoid Create Multiple Album in iOS Swift 5


Do you ever have an application that can download photo from your app to your album gallery ? It's not so complicated to do it, if you have the library that I will share to you right now. When you save your photo sometimes you need to create the album first then put the images in there. So It's neat too look. You can name your album with name of your app name.

So the trick is everytime user will download you call create album method. In this method you check first if there's an same album created or not. If it's not then creating new one otherwise don't create. Because in iOS create same name, it's permitted. So it will be bad if you create many albums with same name.

And if you reinstall the app, maybe the app will create the same album if you don't check. So it's our job as programmer to handle it. To make the user doesn't need to delete the same album. I personally want to know the way before I didn't reliaze that my app create multiple albums after I check it manually. So after I found it multiple, I try to find the way on the internet and finally it's not hard to do.




So this is the code.


Yeah, First you need to import Photos to use the library. I don't give you full of my code but the important to avoid multiple album in this code. I assume you're an expert so I don't need to give you detail.

After you implement code above you will never get multiple album. I have tried it and it works like a charm. Remember you need to call it evertime you run downloading photo in your app. And that's it. So if have any question please free ask or comment below.

Popular posts from this blog

How to restart the app with flutter Android and iOS

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android