 iOS Code Review | Curated code improvement tips

By  iOS Code Review

Bi-weekly newsletter amplifying code improvement tips from the Apple developer community. Swift, Objective-C, iOS, macOS, SwiftUI, UIKit and more. Curated by Marina Gornostaeva and published every other Thursday.

Bi-weekly newsletter amplifying code improvement tips from the Apple developer community. Swift, Objective-C, iOS, macOS, SwiftUI, UIKit and more. Curated by Marina Gornostaeva and published every other Thursday.

By subscribing, you agree with Revue’s Terms of Service and Privacy Policy and understand that  iOS Code Review | Curated code improvement tips will receive your email address.

960

subscribers

15

issues

#15・

 iOS Code Review | Curated code improvement tips - Issue #15

Adding a shim layer is a great way to approach moving to Swift in an Objective-C codebase. I can confirm from hands-on experience practicing it successfully on large ObjC projects.I had this tweet saved in bookmarks for a while, thinking maybe I'll write an a…

 
#14・

 iOS Code Review | Curated code improvement tips - Issue #14

There are multiple problems with splitting words by punctuation and whitespace - even in English "shouldn't" would split into two 'words'. And some languages don't even have spaces. Full article: Three Ways to Enumerate the Words In a String Using Swift by @s…

 
#13・

 iOS Code Review | Curated code improvement tips - Issue #13

On iOS 15, iOS might pre-warm your app by initialising the app delegate & co few minutes before the user launches the app. application(:didFinishLaunching:...) will be called when the app is finally launched, but other resources are loaded earlier. The cu…

 
#12・

 iOS Code Review | Curated code improvement tips - Issue #12

Two neat ways to deal with the good old (and annoying) translatesAutoresizingMasksIntoConstraints 👍

 
#11・

 iOS Code Review | Curated code improvement tips - Issue #11

Once I spent a whole day debugging a text truncation issue in SwiftUI. I had a list of views with multiline text in each. All was good, but on rare occasions one of the views would have truncated text. It would be seemingly random - the same item would be tru…

 
#10・

 iOS Code Review | Curated code improvement tips - Issue #10

While it's undoubtedly a superior way to write asynchronous code, I generally stayed away from async/await-related tips, because no one could really use them yet. I wrote about the issues few weeks ago. But not for much longer!Xcode 13.2 beta was released yes…

 
#9・

 iOS Code Review | Curated code improvement tips - Issue #9

SwiftUI previews can be very handy for other use-cases besides previewing SwiftUI views. You can use previews to preview UIKit views, which can save you dozens of hours in rebuilding to see your changes:

 
#8・

 iOS Code Review | Curated code improvement tips - Issue #8

Considering to start using async/await for real? Here are some things worth knowing before you do. Backporting to older iOS versions is proving challenging and might not happen; and a few serious issues and crashes have been found on the current version shipp…

 
#7・

 iOS Code Review | Curated code improvement tips - Issue #7

It's almost a tradition now to start the newsletter with a tip about an obscure Combine issue... This time, it turned out that breakpointOnError() crashes apps. To solve this, you can make an extension that conditionally uses this only if debugger is attached…

 
#6・

 iOS Code Review | Curated code improvement tips - Issue #6

Have you seen code that's running multiple async calls in a loop, calling completion on the last item in the loop? Or counting the number of callbacks called? I've seen it a lot, and the last time has prompted me to share this tip 🙂DispatchGroup allows you to…

 
#5・

 iOS Code Review | Curated code improvement tips - Issue #5

Do you remember about this obscure feature added in iOS 14? Holding the back button shows the navigation stack history and lets you navigate to any item. Cool feature, right? Not so fast...The titles are taken from the back button. If you're still hiding the …

 
#4・

 Code Review | Curated code improvement tips - Issue #4

@swiftandtips found a well-structured writeup on when to use and not to use [weak self] in closures. Here's a concise chart to help you decide. If you also want to learn the why's, read the full article: You don’t (always) need [weak self] by @BesherMaleh

 
#3・

 Code Review | Curated code improvement tips - Issue #3

Last week a particular topic resonated through the community: the mental toll the different architectures bring on developers. The issue is especially prominent for complex architectures such as VIPER, which is known for having many similarly-named small file…

 
#2・

 Code Review | Curated code improvement tips - Issue #2

If you write Swift, most likely you use structs a lot. John Sundell goes in depth on how marking functions in structs mutating can help you make code more structured and concise.

 
#1・

 Code Review - Issue #1 | Highlights from 2020

While multiline change suggestions were introduced on Github all the way back in February 2020, it's such a time saver during code reviews, that it is worth reminding about. When a you use change suggestions in PR comments, the changes can be incorporated aut…