Error Handling

A class support for throwing, catching, propagating, and manipulating recoverable errors at runtime. When an optional fails, it’s useful to understand what cause the failure, so that the code can respond accordingly. Example: Reading a file from the disk may be fail in some way. File not exist Have no permission to read. File not being encoded in a compatible format. Distinguishing among these different situations allows a program to resolve some errors and to communicate to the user any errors it can’t resolve....

May 7, 2022

Deinitialization

Before the object is recycle, the deinitializer solve the post events.

May 2, 2022

Initialization

The class’s initializer set the original state for the object.

April 30, 2022

Inheritance

A class inherit another class call super class, and get some ability from super class.

April 24, 2022

Method

The object have some method to provide functionality.

April 17, 2022

Properties

Stored properties Only provided by classed and structures. Computed properties Provide by classes, structures, enumerations. Usually associated with instance of a particular type, can be associated with the type itself(type properties). Can define property observers to monitor changes in a property’s value, which can respond to with custom action. Can use a property wrapper to reuse code in the getter and setter. Stored Properties **struct Setting { var width: Int let height: Int } var appSetting = Setting(width: 100, height: 200) appSetting....

April 17, 2022

Structures and Classes

The object oriented programming.

April 10, 2022

Enumerations

Syntax enum Direction { case up case down case left case right } Multiple case can appear on a single line, separated by commas: enum { case up, down, left, right } Use the Enumeration var dir = Direction.up When we want to modify the var after the initialized, we can use a shorter form of the enumeration. var dir = Direction.up dir = .down // The value's type has been inferred when the value is in initializing....

April 10, 2022

Subscripts

Set subscript(index: Int) in the class to index the data of the instance of the this class.

April 10, 2022

Closures

The closures can cantains something by the curly bracket.

April 2, 2022