Get Prepared for Swift 3.0 Changes

The upcoming Swift 3.0 brings several changes, and you’ll have to adapt your code so that it builds after the update.

Our video shows some of the most important changes that will be included in Swift 3.0. Since this version is still under development, further changes may also appear.
We are going to publish updates as new changes are announced. Don’t forget to subscribe to our channel to be notified when a new update is available.

1. lowerCamelCase instead of UpperCamelCase for enums and properties

In Swift 3.0, all properties, enums and parameters will start with lower case letters.
Enumeration values are also changing from upper camel case to lower camel case. All these changes apply to Apple properties and enums, so better get used to it.

2. All method parameters must have labels

In Swift 2.x, the name of the first parameter was usually included in the method’s name.

This will be different in Swift 3.0: all parameters should have labels, including the first one.
This change will break everything since it will also be reflected in Apple’s public methods.

Delegate methods like viewWillAppear, table view’s cellForRowAtIndexPath, etc. will still follow the old style, but in Swift 3 they will include an underscore before the first parameter to indicate that the caller won’t use a parameter label.

3. Redundant words will be omitted

Swift 3 introduces another breaking change: method names that include self-evident words will have those words removed.

Method names become significantly shorter, and useless repetitions are history. The new method names may cause some confusion at first (and also broken build), yet they make a lot of sense.

4. Swift 3 way of importing C Functions

Swift 3 introduces attributes for C functions, which allows for better ways to import C functions into Swift.

For example, CGContext functions get mapped to property methods of CGContext instances.

5. Swift 3 Method names

When a method is described by a verb (for example sort, translate, move), the verb’s imperative shall be used for the mutating method. By mutating method, we refer to methods which modify the caller itself.

Non-mutating counterparts shall apply the “ed” or “ing” suffix.

Don’t forget to subscribe to our channel to be notified when a new update is available.

One Comment

  1. Swift Style Guide – Leakka January 17, 2017 at 12:05 pm - Reply

    […] great Swift code. Programming in Swift requires you to adhere to some linguistic and other rules. Swift 3.0 brought a plethora of changes and you must wrap your head around the new rules to implement them […]

Leave A Comment