Skip to content

Latest commit

 

History

History

day-050

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Day 50: Milestone for Projects 10-12

Follow along at https://www.hackingwithswift.com/100/50.

📒 Field Notes

This day resolves around recapping the content covered while going through Projects 10-12 in Hacking with Swift, and then implementing a challenge project. Regarding the recap, I won't try to rehash what I wrote up already — but a few extra things are worth noting.

touchesBegan

  • When touchesBegan is called in a SpriteKit GameScene, it has the following signature:
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)

The touches set is guaranteed to contain at least one touch, so we can use implicit unwrapping of Array.first without much concern:

let touch = touches.first!

UserDefaults and type safety

While UserDefaults provides a type-safe getters for "simple" types — and even an array of strings — getting more complex objects is a different story.

let photos = UserDefaults.standard.object(forKey: "Photos") as? [Photo] ?? [Photo]()

If you weren't good at nil coalescing before, you will be now 😛.

🥅 Challenge Project

From https://www.hackingwithswift.com/guide/5/3/challenge:

Put two different projects into one: Let users take photos of things that interest them, add captions to them, then show those photos in a table view. Tapping the caption should show the picture in a new view controller.

Feel free to peruse the finished project here ✌️.

screenshot