andersonbarutti / iOS-Swift

Swift Reference

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS - Swift Reference

This is a playground that I made based on the Apple Swift documentation and then I added some samples of general code like Notifications, JSON Serialization and REST Requests. This project requires XCode 7.

Feel free to take a look and if you want to add something, pull requests are welcome :)

Contents

Constants and Variables

  • Constants
  • Variables
  • Type Annotations
  • Emoji Names
  • Printing
  • Comments
  • Integer
  • Float
  • Double
  • Boolean
  • String
  • Tuples
  • Type aliases
  • Converting types

Operators and Comparison

  • Assignment
  • Arithmetic
  • Increment and Decrement
  • Unary Minus
  • Compound Assignment
  • Binary Comparison
  • Logical NOT
  • Logical AND
  • Logical OR
  • Compound
  • Ternary Conditional
  • Switch
  • Switch With Interval Matching
  • Switch With Tuples
  • Switch Value Bindings
  • Switch Where
  • Switch Fallthrough
  • Checking API Availability

Optionals

  • Declaration
  • Unwrapping
  • Can set nil
  • Testing
  • Optional Binding

Strings and Characters

  • String Literals
  • Empty String
  • Mutability and Concatenation
  • Interpolation
  • Characters
  • Counting Characters
  • Indices
  • Inserting and Removing
  • Comparing
  • Prefix and Suffix Equality
  • UTF-8, UTF-16 and Scalar Representation

Arrays

  • Empty Array
  • Array with a Default Value
  • Adding Two Arrays Together
  • Array with an Array Literal
  • Array Count
  • Check if it is Empty
  • Modifying an Array
  • Iterating Over an Array
  • Sorting Arrays
  • Sorting Tuples/Objects

Sets

  • Empty Set
  • Set with an Array Literal
  • Set Count
  • Check if it is Empty
  • Modifying a Set
  • Iterating Over a Set
  • Sorting Sets - Returns Array
  • Set Operations
  • Membership and Equality
  • Is Equal
  • Is Subset Of
  • Is Superset Of
  • Is Disjoint With - does not have any values in common

Dictionaries

  • Empty Dictionary
  • Dictionary with a Dictionary Literal
  • Dictionary Count
  • Check if it is Empty
  • Modifying a Dictionary
  • Iterating Over a Dictionary
  • Get Dictionary List

Loops

  • For-In - Closed Range
  • For-In - Half-Open Range
  • For-In - Don't need to declare index
  • For-In - Iterating Over an Array
  • For-In - Iterating Over a Dictionary
  • For
  • While
  • Repeat-While
  • Continue - go to the next index
  • Break - stop the loop or switch
  • Labeled Loop

Functions

  • Defining and Calling Functions
  • Single Parameter
  • Multiple Parameters
  • Specifying External Parameter Names
  • Omitting External Parameter Names
  • Default Parameter Values
  • Variadic Parameters
  • Variable Parameters
  • In-Out Parameters
  • Return Values
  • Optional Return Value
  • Multiple Return Values - Tuple
  • Function Types
  • Function Types as Parameter Types
  • Function Types as Return Types
  • Nested Functions

Closures

  • The Sort Method
  • Inferring Type From Context
  • Implicit Returns from Single-Expression Closures
  • Shorthand Argument Names
  • Operator Functions
  • Trailing Closures
  • Capturing Values
  • Closures Are Reference Types
  • Autoclosures
  • Escaping - Using variables from outside the closure

Enumerations

  • Enumeration Syntax
  • Matching Enumeration Values with a Switch Statement
  • Associated Values
  • Raw Values
  • Implicitly Assigned Raw Values
  • Initializing from a Raw Value
  • Recursive Enumerations

Structures

  • Definition Syntax
  • Structure Instances
  • Accessing Properties
  • Structures Are Value Types
  • Methods

Classes

  • Classes Are Reference Types
  • Lazy Stored Properties
  • Computed Properties
  • Read-Only Computed Properties
  • Property Observers
  • Type Property
  • Singleton
  • Instance Methods
  • Local and External Parameter Names for Methods
  • Type Methods
  • Initialization
  • Deinitialization
  • Subscripts
  • Returning String
  • Inheritance
  • Overriding Methods
  • Overriding Properties
  • Overriding Property Observers
  • Preventing Overrides
  • Optional Property Types
  • Weak References
  • Unowned References

Error Handling

  • Representing Errors
  • Propagating Errors Using Throwing Functions
  • Handling Errors Using Do-Catch
  • Converting Errors to Optional Values
  • Disabling Error Propagation
  • Specifying Cleanup Actions

Type Casting

  • Defining a Class Hierarchy for Type Casting
  • Checking Type
  • Downcasting
  • Type Casting for AnyObject
  • Type Casting for Any

Nested Types

  • Nested Types in Action
  • Referring to Nested Types

Extensions

  • Computed Properties
  • Initializers
  • Methods
  • Mutating Instance Methods
  • Subscripts
  • Nested Types

Protocols

  • Property Requirements
  • Method Requirements
  • Initializer Requirements
  • Delegation
  • Adding Protocol Conformance with an Extension
  • Collections of Protocol Types
  • Protocol Inheritance
  • Class-Only Protocols
  • Protocol Composition
  • Checking for Protocol Conformance
  • Optional Protocol Requirements
  • Protocol Extensions
  • Adding Constraints to Protocol Extensions

Generics

  • Generic Functions
  • Generic Types
  • Extending a Generic Type
  • Type Constraints
  • Associated Types
  • Extending an Existing Type to Specify an Associated Type
  • Where Clauses

Access Control

  • Access Control Syntax
  • Custom Types
  • Enumeration Types
  • Subclassing
  • Constants, Variables, Properties, and Subscripts

Advanced Operators

  • Bitwise NOT Operator
  • Bitwise AND Operator
  • Bitwise OR Operator
  • Bitwise XOR Operator
  • Bitwise Left and Right Shift Operators
  • Overflow Operators
  • Operator Functions
  • Prefix and Postfix Operators
  • Compound Assignment Operators
  • Equivalence Operators
  • Custom Operators
  • Precedence and Associativity for Custom Infix Operators

Notification Center

  • Adding and Removing Observer for a Notification
  • Posting a Notification
  • Executing

JSON Serialization

  • JSON Data
  • Serialization

REST Request

  • Creating a Manager
  • Executing and Canceling

Operations

  • Block Operation
  • Priority and Quality of Service
  • Custom Operation
  • Main and Current Queue
  • Operation Queue
  • Cancelling Operations
  • Dependencies

Grand Central Dispatch

  • Global Concurrent Dispatch Queues
  • Getting Main Queue at Runtime
  • Creating Serial Dispatch Queues
  • Synchronous Task
  • Asynchronous Task
  • Getting back to the main queue
  • Suspending and Resuming Queues
  • Dispatch at the specified time
  • Dispatch queue for multiple invocations
  • Dispatch once and only once for the lifetime of an application
  • Using Dispatch Semaphores to Regulate the Use of Finite Resources
  • Waiting on Groups of Queued Tasks

About

Swift Reference

License:MIT License


Languages

Language:Swift 100.0%