Tag Archives: Swift

Daylight may ruin your date

(No, this post doesn’t include dating advice. For such content, your best shot is probably YouTube. :-)) This is instead about Date values in Swift*. Which sometimes you might need to update by “components”. Such as by adding a specific number … Continue reading

Posted in Swift | Tagged , , , , , | Leave a comment

Enum cases with associated values are powerful but we need follow-up patterns

Let’s assume we want to use Swift to develop a function to round floating point numbers, in different ways according to a context. For example, sometimes the result of such rounding could be the input value itself (like on a … Continue reading

Posted in Swift | Tagged , , , , , , | Leave a comment

Swift events: almost generic, almost solution(s)

I have been thinking about a possible better/generic solution for adding multi-cast delegate/event dispatching support to Swift class hierarchies since January, i.e. since more than 6 months ago. While in my opinion the solution below is still not better than … Continue reading

Posted in Swift | Tagged , , , , | Leave a comment

Testing Swift deinit

As you probably know, Swift uses ARC for memory management (presumably to improve performance over classic garbage collection based systems). That means it is very important that you do use weak (or unowned) references whenever cycles could form. For example, when you implement … Continue reading

Posted in Swift | Tagged , , , , | Leave a comment

Swift impressions

After about one year of (intermittently) learning Swift and recently also using the language in a (hopefully) real project, I can conclude that it is very powerful, yet clean, easy to read and understand (that is important!), and does an exceptional job on preventing human errors … Continue reading

Posted in Swift | Tagged , , , | Leave a comment

Why I love Swift protocol extensions

Let’s develop a small framework, allowing client developers to use working schedule objects. Each schedule would be based on an interval of days: from a start day to a finish day (specified by numbers). Optionally, client developers may configure specific … Continue reading

Posted in iOS, macOS, Swift | Tagged , , , , , | Leave a comment

Swift events

Swift does not have built-in .NET-like events. (I admit, I was used to have them in C#, although implementing the weak pattern in .NET was not the easiest job either.) Instead, in Swift there are two common patterns that developers (and even Apple) … Continue reading

Posted in Swift | Tagged , , , , , | 4 Comments