Tag Archives: Swift

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

Swift selectors and number of arguments

In Swift, you can create and “perform” a #selector like below (e.g. in an iOS app) and it seems to work just fine (i.e. executes the “selected” function): class Obj1 : NSObject {     var value: String?     … Continue reading

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