Category Archives: Swift

Swift issues and solutions

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

Swift optionals can save the day

Although generics in Swift are somehow limited at this time, there is a nice variance-related feature available when using optionals: you can assign a non-optional to an optional variable, an array of non-optionals to an array of optionals (these two are classics), … 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

Drag gesture recognizer for iOS/macOS development (with initial location)

As everybody knows, when using a mouse on a computer a drag operation occurs when the mouse button is pressed, then the device is moved, and eventually the button is released. It’s a continuous and precise operation. In iOS we have … Continue reading

Posted in iOS | 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