Have you ever been to a conference or a meetup, chatted to someone new, then realized seconds after you walk away that you’ve already forgotten their name? You’re not alone, and the app you’re building today will help solve that problem and others like it.
Your goal is to build an app that asks users to import a picture from their photo library, then attach a name to whatever they imported. The full collection of pictures they name should be shown in a List
, and tapping an item in the list should show a detail screen with a larger version of the picture.
Breaking it down, you should:
PhotosPicker
to let users import a photo from their photo library.Remember to import the user's photo as Data
, so you can write it out easily.
You can use SwiftData for this project if you want to, but it isn’t required – a simple JSON file written out to the documents directory is fine, although you will need to add a custom conformance to Comparable
to get array sorting to work.
If you do choose to use SwiftData, here's an important tip: when storing large data like images or movies in your models, define them using a special @Attribute
macro like this:
@Attribute(.externalStorage) var photo: Data
That tells SwiftData not to save the image data directly inside its database, but to put it alongside instead – it's much more efficient.
Remember, you already know everything you need to make this work – good luck!
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
Link copied to your pasteboard.