Private APIs, Objective-C runtime, and Swift
Sep 8, 2020, 7:36 AM
Sometimes when building an app, we find ourselves in a situation when we want to use a private API. It may provide some important functionality that is not exposed (yet), or we may want to work around a known platform issue. Or, you may be...
For the if and guard statements I usually just merge two conditions together like this:
Sep 8, 2017, 6:15 PM
For the if and guard statements I usually just merge two conditions together like this:if let title = textField.text, !title.isEmpty { // title String is now unwrapped, non-empty, and ready for use}And I really miss old where keyword...
Andrea Bizzotto thanks for an update for Swift 4!
Sep 5, 2017, 4:55 PM
Andrea Bizzotto thanks for an update for Swift 4!Actually, since strings are now collections, we can use dropFirst function instead of old substring call: String(term.dropFirst()).I’m adding another TODO to update the gist after Swift...
Thanks for the feedback and sorry for late response.
Aug 28, 2017, 5:48 AM
Thanks for the feedback and sorry for late response.Localization toolbox became much better in modern versions on Xcode. Everything depends on your product scale, development workflow and personal taste of course.Still there are some...
DRY String Localization with Interface Builder
Aug 21, 2017, 7:35 AM
Great applications should have great localization. And users will appreciate an option to use beloved apps in their native language. There is no excuse for developers not to support interface localization even on early stages of the...
Generic Optional Handling in Swift
Aug 13, 2017, 12:56 PM
Sometimes you want to write a generic algorithm working on any Optional type no matter what actual type is wrapped inside. Ok, this can be easily done with a free generic function, but what if you want to write a Sequence extension to...
Using Self in Swift Class Extensions
Aug 10, 2017, 1:45 PM
It might be tempting to use Self as a parameter type when extending classes but Swift only allows it in a protocol or as the result of a class method invocation.In fact, this is a semantically correct restriction for non-final classes in...
Thanks for the feedback, Vasyl Myronchuk!
Aug 9, 2017, 3:20 PM
Thanks for the feedback, Vasyl Myronchuk!R.swift looks interesting but may be an overkill in some cases. I usually try to get as far as I can with class name matching and generate localization and asset accessors with a simple...
Managing Temporary Files in Swift
Aug 8, 2017, 11:46 AM
Reference counting is great in taking unused objects out of memory. The same can be applied to the temporary files we allocate.Let’s say you are building a video sharing app, here is what you have to do each time user decides to upload...
Storyboard Tricks
Aug 6, 2017, 10:08 AM
While looking through another sample project today, I have once again noticed how many string literals and force downcasts accompany most of the storyboard-related code.Having realized that, I decided to share a few practices I use myself...