Swift Tutorial - Tutorialspoint

(backadmin) #1

  • Type Inference



    1. SWIFT – VARIABLES



    • Variable Declaration

    • Type Annotations

    • Naming Variables

    • Printing Variables





    1. SWIFT – OPTIONALS



    • Forced Unwrapping

    • Automatic Unwrapping

    • Optional Binding





    1. SWIFT – CONSTANTS



    • Constants Declaration

    • Type Annotations

    • Naming Constants

    • Printing Constants





    1. SWIFT – LITERALS



    • Integer Literals

    • Floating-point Literals

    • String Literals

    • Boolean Literals





    1. SWIFT – OPERATORS



    • Arithmetic Operators...........................................................................................................................

    • Comparison Operators

    • Logical Operators

    • Bitwise Operators

    • Assignment Operators iv

    • Range Operators..................................................................................................................................

    • Misc Operators

    • Operators Precedence





    1. SWIFT – DECISION MAKING



    • if Statement.........................................................................................................................................

    • if-else Statement

    • if...else if...else Statement

    • Nested If Statements

    • Switch Statement

    • The? : Operator





    1. SWIFT – LOOPS



    • for-in Loop

    • Swift – for Loop

    • Swift – while Loop

    • Swift – do-while Loop

    • Loop Control Statements

    • Swift – continue Statement

    • Swift – break Statement

    • Swift – Fallthrough Statement





    1. SWIFT – STRINGS



    • Create a String

    • Empty String

    • String Constants

    • String Interpolation

    • String Concatenation

    • String Length v

    • String Comparison

    • Unicode Strings

    • String Functions & Operators





    1. SWIFT – CHARACTERS



    • Empty Character Variables

    • Accessing Characters from Strings

    • Concatenating Strings with Characters





    1. SWIFT – ARRAYS



    • Creating Arrays

    • Accessing Arrays

    • Modifying Arrays

    • Iterating Over an Array

    • Adding Two Arrays

    • The count Property

    • The empty Property





    1. SWIFT – DICTIONARIES



    • Creating Dictionary

    • Accessing Dictionaries

    • Modifying Dictionaries

    • Remove Key-Value Pairs

    • Iterating Over a Dictionary

    • Convert to Arrays

    • The count Property

    • The empty Property





    1. SWIFT – FUNCTIONS



    • Function Definition vi

    • Calling a Function

    • Parameters and Return Values

    • Functions without Parameters

    • Functions with Return Values

    • Functions without Return Values

    • Functions with Optional Return Types

    • Functions Local Vs External Parameter Names

    • External Parameter Names

    • Variadic Parameters

    • Constant, Variable, and I/O Parameters

    • Function Types & its Usage

    • Using Function Types

    • Function Types as Parameter Types & Return Types............................................................................

    • Nested Functions





    1. SWIFT – CLOSURES...........................................................................................................



    • Expressions in Closures

    • Single Expression Implicit Returns

    • Known Type Closures

    • Declaring Shorthand Argument Names as Closures

    • Closures as Operator Functions

    • Closures as Trailers

    • Capturing Values and Reference Types





    1. SWIFT – ENUMERATIONS



    • Enumeration Functionality

    • Enumeration with Switch Statement

    • Difference between Associated Values and Raw Values vii

    • Enum with Associated Values

    • Enum with Raw Values





    1. SWIFT – STRUCTURES



    • Definition of a Structure

    • Accessing the Structure and its Properties

    • Best Usage Practices of Structures





    1. SWIFT – CLASSES



    • Class Identity Operators





    1. SWIFT – PROPERTIES



    • Stored Properties

    • Lazy Stored Property

    • Instance Variables

    • Computed Properties

    • Local and Global Variables

    • Type Properties

    • Querying and Setting Properties





    1. SWIFT – METHODS



    • Instance Methods

    • Local and External Parameter Names

    • External Parameter Name with # and _ Symbol

    • Self property in Methods

    • Modifying Value Types from Instance Methods

    • Self Property for Mutating Method

    • Type Methods





    1. SWIFT – SUBSCRIPTS viii



    • Subscript Declaration Syntax and its Usage

    • Options in Subscript





    1. SWIFT – INHERITANCE



    • Base Class

    • Subclass

    • Overriding

    • Methods Overriding

    • Property Overriding

    • Overriding Property Observers

    • Final Property to prevent Overriding





    1. SWIFT – INITIALIZATION



    • Initializer Role for Stored Properties..................................................................................................

    • Setting Property Values by Default

    • Parameters Initialization

    • Local & External Parameters

    • Parameters without External Names

    • Optional Property Types

    • Modifying Constant Properties During Initialization

    • Default Initializers

    • Memberwise Initializers for Structure Types

    • Initializer Delegation for Value Types

    • Class Inheritance and Initialization

    • Initializer Inheritance and Overriding

    • Failable Initializer

    • Failable Initializers for Enumerations

    • Failable Initializers for Classes ix

    • Overriding a Failable Initializer

    • The init! Failable Initializer

    • Required Initializers





    1. SWIFT – DEINITIALIZATION.............................................................................................



    • Deinitialization to Deallocate Memory Space





    1. SWIFT – ARC OVERVIEW



    • Functions of ARC

    • ARC Program

    • ARC Strong Reference Cycles Class Instances

    • ARC Weak and Unowned References

    • Strong Reference Cycles for Closures

    • Weak and Unowned References





    1. SWIFT – OPTIONAL CHAINING........................................................................................



    • Optional Chaining as an Alternative to Forced Unwrapping

    • Defining Model Classes for Optional Chaining & Accessing Properties

    • Calling Methods Through Optional Chaining

    • Accessing Subscripts through Optional Chaining

    • Accessing Subscripts of Optional Type

    • Linking Multiple Levels of Chaining

    • Chaining on Methods with Optional Return Values





    1. SWIFT – TYPE CASTING



    • Defining a Class Hierarchy

    • Type Checking

    • Downcasting

    • Typecasting:Any and Any Object

    • AnyObject.......................................................................................................................................... x





    1. SWIFT – EXTENSIONS



    • Computed Properties

    • Initializers

    • Methods

    • Mutating Instance Methods

    • Subscripts

    • Nested Types





    1. SWIFT – PROTOCOLS



    • Property and Method Requirements

    • Mutating Method Requirements

    • Initializer Requirements

    • Class Implementations of Protocol Initializer Requirements

    • Protocols as Types

    • Adding Protocol Conformance with an Extension

    • Protocol Inheritance

    • Class Only Protocols

    • Protocol Composition

    • Checking for Protocol Conformance





    1. SWIFT – GENERICS



    • Generic Functions: Type Parameters

    • Extending a Generic Type

    • Type Constraints

    • Associated Types

    • Where Clauses





    1. SWIFT – ACCESS CONTROL



  • Access Control for Function types xi

  • Access Control for Enumeration types

  • Access Control for SubClasses

  • Access Control for Constants, variables, properties and subscripts

  • Getters and Setters

  • Access Control for Initializers and Default Initializers

  • Access Control for Protocols

  • Access Control for Extensions

  • Access Control for Generics

  • Access Control for Type Aliases

Free download pdf