Monday, January 19, 2015

The Swift Programming Language Note 3 (From Inheritance to Advanced Operators) Completed

The Swift Programming Language Note 3 (From Inheritance to Advanced Operators) Completed
1. Inheritance
Any class that does not inherit from another class is known as a base class.
Swift classes do not inherit from a universal base class.
You can prevent a method, property, or subscript from being overridden by marking it as final.
Do this by writing the final modifier before the method, property, or subscript’s introducer keyword

2. Initialization
an initializer is like an instance method with no parameters, written using the init keyword
If you do not want to use an external name for an initializer parameter, write an underscore (_) instead
of an explicit external name for that parameter to override the default behavior.

3. Deinitialization
A deinitializer is called immediately before a class instance is deallocated. You write deinitializers
with the deinit keyword, similar to how intializers are written with the init keyword. Deinitializers are only available on class types.

4. Automatic Reference Counting
Swift uses Automatic Reference Counting (ARC) to track and manage your app’s memory usage. In most cases, this means that memory management
“just works” in Swift, and you do not need to think about memory management yourself. ARC automatically frees up the memory used by class
instances when those instances are no longer needed.

5. Optional Chaining
Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil. If
the optional contains a value, the property, method, or subscript call succeeds; if the optional is nil, the property, method, or subscript
call returns nil. Multiple queries can be chained together, and the entire chain fails gracefully if any link in the chain is nil.

6. Access Control
n addition to offering various levels of access control, Swift reduces the need to specify explicit access control levels by providing default
 access levels for typical scenarios. Indeed, if you are writing a single-target app, you may not need to specify explicit access control levels at all.
 Swift provides three different access levels for entities within your code. These access levels are relative to the source file in which an entity is defined, and also relative to the module that source file belongs to.

Public access enables entities to be used within any source file from their defining module, and also in a source file from another module that
imports the defining module. You typically use public access when specifying the public interface to a framework.
Internal access enables entities to be used within any source file from their defining module, but not in any source file outside of that module.
You typically use internal access when defining an app’s or a framework’s internal structure.
Private access restricts the use of an entity to its own defining source file. Use private access to hide the implementation details of a
specific piece of functionality.

7. Advanced Operators

No comments:

Post a Comment