Issue #39
Hi there,
Welcome to issue #39, the last one in 2022. I wish you wonderful holidays, and see you on January 5 👋
Supporting webp images with PHPicker
Are you using PHPickerViewController
for photo library imports, and access images using loadObject(ofClass:)
? It turns out, this method doesn't support some image formats, such as webp
images. You can use loadDataRepresentation(forTypeIdentifier: "public.image", completionHandler:)
instead.
Equality vs Identity
How is ===
different from ==
?===
checks if it's the same instance, and is available only for classes. But why do we almost never have to use it?
All NSObject
s ( UIView
, UIViewControllers
, etc) get a default Equatable
conformance that uses Objective-C's isEqual:
, which in turn compares instances, like ===
would. So when writing checks like if sender == myButton
, we actually mean ===
, but can save one character thanks to Swift's interoperability with Objective-C.
Codelime is a powerful code snippet manager with many dev tools for iOS development. Save and manage your code snippets across iPhone, iPad and Mac with Codelime.
Take advantages of many dev tools available in Codelime (Hash, Text Case, Color Picker, Generate Asset Catalog, Make Pretty Code Snippet, ...) to boost your every day iOS development workflow.
Made by indie developers. Try it for free ↗️
More formatter coolness
I can't stop being amazed by all the different features available in formatters out of the box:
Readable large numbers
We can arbitrarily add _
's inside any type of number literal - integers, floats or even hex numbers:
My top 5 tips
I teamed up with Vincent to record a 20 min. video where I share my top tips to improve your Swift code. Some of them have been featured in the newsletter earlier, but some have not:
- Avoiding Retain Cycles with Combine or RxSwift
- Typesafe Identifiers
- Managing Complex UI States
- Never Forget to Call a Completion Handler
- Simplifying UI Code with Layout Margins
- Typesafe Strings and Images
If you haven't seen the video yet, do check it out ☺️
✌️
Alright, that's it for today! Thank you to Codelime for sponsoring this issue.
I'm curious if you found one of the tips particulary interesting - let me know by replying to this email!
Happy holidays 🕎🎄
Member discussion