​Quick is just a strong and user-friendly coding language for macOS, iOS, watchOS and tvOS....

Page 10

Swift

Failable Initializers for Classes ........................................................................................................... 150 Overriding a Failable Initializer .......................................................................................................... 150 The init! Failable Initializer ................................................................................................................ 152 Required Initializers ........................................................................................................................... 152

26.

SWIFT – DEINITIALIZATION............................................................................................. 154 Deinitialization to Deallocate Memory Space .................................................................................... 154

27.

SWIFT – ARC OVERVIEW ................................................................................................ 156 Functions of ARC ............................................................................................................................... 156 ARC Program ..................................................................................................................................... 156 ARC Strong Reference Cycles Class Instances ..................................................................................... 157 ARC Weak and Unowned References ................................................................................................ 158 Strong Reference Cycles for Closures ................................................................................................. 160 Weak and Unowned References ........................................................................................................ 161

28.

SWIFT – OPTIONAL CHAINING........................................................................................ 163 Optional Chaining as an Alternative to Forced Unwrapping .............................................................. 163 Defining Model Classes for Optional Chaining & Accessing Properties .............................................. 165 Calling Methods Through Optional Chaining ..................................................................................... 167 Accessing Subscripts through Optional Chaining ............................................................................... 169 Accessing Subscripts of Optional Type ............................................................................................... 172 Linking Multiple Levels of Chaining .................................................................................................... 175 Chaining on Methods with Optional Return Values ........................................................................... 178

29.

SWIFT – TYPE CASTING .................................................................................................. 181 Defining a Class Hierarchy ................................................................................................................. 181 Type Checking ................................................................................................................................... 182 Downcasting ...................................................................................................................................... 184 Typecasting:Any and Any Object ....................................................................................................... 186 ix


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.