Blog Archives

Lightning tour of functions in Swift

Check out this video tutorial with a lightning tour of functions in Swift. It covers: Parameter default values Optional function parameters Overloading a function If you’re interested in more of these sorts of videos, I’ll be posting frequently over on the

Tagged with: , , , ,
Posted in Swift

Parameter defaults and Optional Function Parameters in Swift 3.0

There are more changes in Swift 3.0 to Optional Function parameters, so I thought I should revisit this blog post. Functions no longer include the name of the first parameter in the function name, and the first parameter is no different

Tagged with: , ,
Posted in Swift

Func parameters in Swift 3.0

Well, Apple’s done it again, and made func parameters even simpler in Swift 3.0! It’s all very straight forward now, class methods, static methods, global functions, init methods – they all work the same now, hooray! 1. Explicit parameter names

Tagged with:
Posted in Swift

Farewell parameter var

In Swift 3.0, the var keyword in function parameters is being removed. Apparently there was too much confusion of var parameters with the functionality of inout parameters. For more information, see the Swift blog announcement, Swift Evolution proposal and swift-evolution-announce post. If you had

Tagged with:
Posted in Swift

Ambiguous convenience initializers

I was just setting up a class with a designated initializer and a convenience initializer to be able to pass in initializing properties beyond the defaults: Great, all good so far. But sometimes a Font will be instantiated with a

Tagged with: ,
Posted in Swift

Parameter defaults and Optional Function Parameters in Swift 2.0

This post has been updated for Swift 3.0 here. This post has been updated for Swift 3.0 here. There are some changes in Swift 2.0 to Optional Function parameters, so I thought I should revisit this blog post. For info just on

Tagged with: , ,
Posted in Swift

Func parameters in Swift 2.0

This post has been updated for Swift 3.0 here. This week func parameters were simplified in Swift 2.0. The hash symbol was deprecated for specifying a parameter should be explicitly named, and the rules were simplified concerning global functions vs

Tagged with:
Posted in Swift

Parameter defaults and Optional function parameters in Swift

This post has been updated for Swift 3.0 here. This post has been updated for Swift 3.0 here. Swift has an interesting multi-pronged approach to dealing with default and optional function parameters, based in part on its relationship with Objective C and

Tagged with: , ,
Posted in Swift

func parameters in Swift

STOP PRESS: Updated for Swift 2.0 here! How function parameters work in Swift can be a little confusing, here’s an attempt to make it clearer: 1. func By default parameters of funcs do not have external names: If you want

Tagged with:
Posted in Swift

Optional parameters in methods in Objective C

Methods in Objective C are actually called messages but they’re often referred to as methods, a more commonly used terminology. Optional parameters are treated in an interesting way in Objective C. Basically there are no optional parameters! In fact the

Tagged with: ,
Posted in Objective C