O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

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

Modern syntax

Swift has a modern syntax that eliminates the verbosity of programming languages such as Objective-C. For instance, the following code example shows an Objective-C class with a property and method. Objective-C classes are defined in two separate files (interface and implementation). The VerboseClass.h file defines an interface as a subclass of the NSObject class. It defines a property, ourArray, and a method, aMethod.

The implementation file imports the header class and provides an implementation for aMethod, as shown in the following code:

//  VerboseClass.h @interface VerboseClass: NSObject @property (nonatomic, strong) NSMutableArray *ourArray; - (void)aMethod:(NSMutableArray*)anArray; @end //  VerboseClass.m #import "VerboseClass.h" ...

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