Learning Swift - For-Loops

Loops are a fundamental building block of any program. Doing repetitive tasks fast and accurately is what computers are really good at and what we humans get very bored doing. Swift offers several different ways to perform loops, but today we are going to concentrate on for-loops. The most basic form of loop is the for-in loop. There are two ways this can be used: looping over the numbers in a range or looping over the elements in an array or dictionary.
Read more →

Learning Swift - Generics

One of the nice things about Swift is how clean your code looks. A lot of the weird characters that pepper the code of other languages has been eliminated: No more semi-colons, asterisks etc. But then you are reading somebody else’s code and you find these angle brackets all over the place and they don’t seem to make sense. What does this mean? func mid<T: Comparable>(array: [T]) -> T It looks like it is a function to find the middle element in an array, but what is <T: Comparable> or [T] or even just T?
Read more →

Singleton to Protocol

I was driving through the town of Singleton the other day and of course, it got me thinking about using singletons in my apps. Singletons were a commonly used pattern in Objective-C programming and appear in many of Apple’s own APIs, but seem to be increasingly frowned upon in the Swift world. So what is a singleton? # A singleton is a class that only expects to have a single instance.
Read more →

Three Rules for Writing Better Swift

  1. Do not use !.
  2. Use let, not var.
  3. Allow the compiler to infer types.

Read on for more details…

Read more →

Configuring Xcode

While not strictly a part of my Learning Swift series, today I thought I would discuss some of the ways to configure and use Xcode to be a more productive and comfortable programmer. 1. Editor color themes and fonts: # Step through the supplied themes and find the best one for you. Then click the ‘+’ button at the bottom of the list and duplicate the selected theme. Now you can tweak it to suit you.
Read more →

How do I start to learn Swift?

The first thing to do is to download the latest version of Apple’s Swift Programming Language book from the iBooks Store. You can just read this book, especially the first section: “A Swift Tour”, but you will get more out of it if you follow along with the playground. There is a link to download the playground from the book which you can use directly if you are reading using iBooks on the Mac.
Read more →

Icon Builder 3.2 Released

Icon Builder 3.2 is now available from the Mac App Store. Icons for Apple Watch apps now have their alpha channel removed. Tidier folder structure for related files (iTunes Artwork files and Read Me). Updated to work with Xcode 7’s Assets.xcassets folders. Creates iPad Pro icons for Xcode 7.2 or later. Fix for Retina Macs creating double-sized images.
Read more →

Why is Swift so great?

Firstly, I can give you the technical answer, as published by Apple: Swift is a new programming language for iOS, OS X, watchOS, and tvOS apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works.
Read more →

Learning Swift - An Introduction

Welcome to Learning Swift. # This is the first post in what I hope will be an extensive series dealing with the Swift language. Here are some of the questions I hope to answer: Should I learn Swift? Why? Why is Swift so great? How should I start learning Swift? I already know Objective-C - how do I convert? After that, I am planning a series of posts discussing the major differences of Swift from the view point of an Objective-C programmer and the aspects of Swift that I found difficult to grasp.
Read more →

New Twitter account

I have started a new Twitter account so that I can provide rapid support to users of my apps. Please contact me @trozware if you have any questions, suggestions, bug reports or would just like to chat. I will also be using this account to promote my new Learning Swift series.
Read more →