How about 5 new tips you can start using today? 💡

Hi 👋

Guess what, today is my birthday! 🎂 And I have a gift for you 😛

Last week I started teaching my course on Combine and the replay of the first session is available for free!

In this first session you will learn all the foundational concepts that Combine relies on 👌

And the course will continue this Thursday, with a second session that will focus on exploring Combine’s operators 🛠️


One of the benefits of spending a lot of time on Twitter (or is it X now? 🤔) is that I see a lot of iOS folks share super useful tips!

So I went through my bookmarks and made you a list of the 5 most useful tips I’ve found 🙌

#01 – Multiline line labels in SwiftUI

If your designers ever asked you to implement a multiline label, you probably remember how challenging it must have been!

But this might be a thing of the past, because iOS 16 introduced a new modifier .lineLimit() that lets you specify how many lines a TextField is allowed to span (and you can even pass a Range!)

#02 – How to lookup error codes

Debugging issues is hard, especially when the only piece of information you have to investigate is this kind of obscure error code: NSError(domain: "NSURLErrorDomain", code: -1003)

But did you know that there’s a website that lets you easily look up which constant an error code might refer to?

#03 – Property Observers x local variables

Because of their names, we tend to think that property observers can only be applied to properties.

But as it turns out, that’s not the case: they also work with local variables!

And this can be particularly useful, especially if you’re debugging a complex piece of code and you want to monitor value change in a variable!

#04 – Displaying animated GIFs natively

If, like me, you ever tried to display an animated GIF in an iOS app, you might have noticed that by default UIImage will only display the first frame of the GIF 😞

Turns out this limitation is no longer true, because there’s now an API to natively display animated GIFs 🎉

#05 – Ever heard of the `for case let` syntax?

Swift is known to have quite a convoluted syntax when it comes to handling enums with associated values…

Did you know that it’s possible to combine a for-in loop and an if-lettogether through the use of the for-case-let syntax?

I don’t recommend using this syntax on a daily basis, but these little pieces of trivia are always worth knowing!

(just promise me you’ll never ask this as an interview question 😛)

That’s all for this email, thanks for reading it!

If you’ve enjoyed it, feel free to forward it
to your friends and colleagues 🙌

I wish you an amazing week!

❤️

Previous
Previous

Discover MeasurementFormatter

Next
Next

Bad practice: capturing a method reference