O'Reilly logo

Swift Translation Guide for Objective-C Users: Develop and Design by Maurice Kelly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Functions

Unless you like to spend most of your time repeating yourself, functions are an essential part of any programming language. Swift functions are a cut above their namesake in Objective-C. A Swift function can be standalone or a method belonging to a class, structure, or enum. They can be created inside another function (known as a nested function), can be passed to other functions as parameters, and even returned from functions as a return value. Given their increased importance, saying that functions are now first-class citizens of the Swift world is a fair statement.

In Objective-C, a distinction is made between functions and methods: A function is very much the domain of C code, and methods belong firmly to Objective-C. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required