100 Days of SwiftUI Day 66

100 Days of SwiftUI – Day 66

We’ve arrived at day 66 of the 100 Days of SwiftUI! We done most of the work for our Instafilter app yesterday. We’ll be putting the finishing touches to it today so that we’ve another project under our belt. To do this, we need to dive into UIKit once again, so let’s take a look!

Customizing our filter using confirmationDialog()

When we finished the first part of the implementation yesterday, the app worked fine. However, users were only able to apply a single effect. This isn’t quite as extensive as we want our app to be, of course, so we’ll need to implement a system that allows our users to choose from multiple filters that are provided by Core Image.

Saving the filtered image using UIImageWriteToSavedPhotosAlbum()

With all of the hard work done by our users to edit their images, it would be a shame if they could not save them to their galleries. As of now, they can’t. However, we’re going to solve this by adding the required functionality to the save button.

As I explained previously, the UIImageWriteToSavedPhotosAlbum() function does everything we need, but it has the catch that it needs to be used with some code that really doesn’t fit well with SwiftUI: it needs to be a class that inherits from NSObject, have a callback method that is marked with @objc, then point to that method using the #selector compiler directive.

Hacking with Swift, Paul Hudson (@twostraws)

Wrap up

And that’s it for day 66 and another project has been added to our portfolio. Not too shabby! This was quite a difficult project, mainly because we had to dip into Apple’s UIKit, which really does work differently from SwiftUI. It’s now time to recharge as we face a challenge day tomorrow. Until then!

Darryl

Hi! My name is Darryl and this is my personal blog where I write about my journey as I learn programming! You'll also find articles about other things that interest me including games, tech and anime.

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

100 Days of SwiftUI – Day 85

100 Days of SwiftUI – Day 14 – Optionals

100 Days of SwiftUI – Day 49

100 Days of SwiftUI – Day 21 – Design