Category Archives: Swift

Thoughts on Swift

A wonderful bouquet of flowers.I was just reading a Slack channel I’m a part of and someone was asking if it’s difficult to add Swift to an Objective-C project. It’s not. Basically you should add a bridging header to your project so you can call your Objective-C code from Swift then do a full nullability audit on any code you’d like to call from Swift. That’s it in a nutshell as far as I can remember.

Another thing to keep in mind as you start writing Swift. Just start writing code. It doesn’t matter if it’s “swifty” or not. I’m an old C/C++ developer and people probably think my Objective-C and Swift look like an old C/C++ developer wrote it. Sure, there are nice things in the language you’ll learn to take advantage of but, to get started, just write code.

Work Note – Swift Thoughts

wrongSwiftLogoI’ve been working in Swift more and more over the past couple months. To get started I wrote a simple parsing class for Agrian, the product I work on. More recently, as in this week, we started doing most work in Swift. The syntax is super sugary and will take some getting used to, but I can already see I’m going to love working in it.

It seems if you have a background in C, C++, or C#, you should feel right at home. I wonder how JavaScript developers feel about it? If you have an opinion feel free to leave a comment, or write about it on your weblog. I’m curious what you have to say.

This afternoon as I was working on the app I found myself wishing I could do something like this with Swift.

[swift light=”true”]let textView = UITextView() {
.userInteractionEnabled = false
.font = .defaultFont(14)
.backgroundColor = .yellowColor()
}[/swift]

It feels like a natural thing to do, I don’t know why, but it does. We’re working in Swift 2.0, so if there is a way to do this, please let me know, I don’t think we can, but I’m such a noob, I’m not sure about much.