Skip to content

tiagobbraga/iOS-Swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  • Nil Coalescing

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-Where - Iterating Over an Array where element meets condition
  • For-In - Iterating Over a Dictionary
  • For
  • While
  • Repeat-While
  • Continue - go to the next index
  • Break - stop the loop or switch
  • Labeled Loop

Predicates

  • Equal
  • Not
  • Less
  • Variables Substitution
  • Between
  • Compound Predicates
  • String BEGINSWITH
  • String CONTAINS
  • String ENDSWITH
  • String LIKE
  • String MATCHES
  • IN
  • Block Predicate

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
  • If Case (Enumeration Case Pattern)

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
  • 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
  • Using methods with NSError
  • 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

Date and Time

  • Creating Date Objects
  • Test Equal Dates
  • Test Earlier Date
  • Test Later Date
  • Test if the difference is less than 60 seconds
  • Calendar Basics
  • Create a Date from Components
  • Extracting Components from Date
  • Converting from One Calendar to Another
  • Adding Components to a Date
  • Getting the difference between two dates
  • Creating Time Zones
  • Changing Time Zone
  • Daylight Saving Time
  • Date Formatter

Notification Center

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

Key Value Observing

  • Contexts
  • Observable Properties
  • Handle observing

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
  • Barrier Synchronous Task
  • Barrier 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

Functional Programming

  • Filtering
  • Reducing
  • Mapping
  • FlatMap
  • Combining uses

Timers

  • Scheduled Timer on the current NSRunLoop
  • Scheduled Timer With Repetition
  • Scheduling Timers Manually
  • Scheduling Timers Manually With Fire Date
  • Firing Timers Manually

File Manager

  • Bundle Directory
  • Documents Directory
  • Documents/Inbox Directory
  • Library Documents
  • Temporary Dicrectory
  • File Manager
  • Contents of a directory
  • Filter by file extension
  • Check if directory or file exists
  • Creating a directory
  • Writing and Reading String Files
  • Deleting a File
  • Directory or File Attributes
  • File Manager Delegate

User Defaults

  • Shared Instance
  • Bool Values
  • Integer Values
  • Float Values
  • Double Values
  • String Value
  • Array Value
  • Dictionary Value
  • Data Value
  • URL Value
  • Removing Defaults
  • Synchronyze
  • Notifications

Core Data

  • Entities
  • Attributes
  • Relationships
  • Entities Properties
  • Managed Object Model
  • Persistent Store Coordinator
  • Managed Object Context
  • Child Managed Object Context for Multithreading
  • Managed Objects
  • Notifications
  • Saving Context
  • Fetch Request
  • Subclassing

About

iOS - Swift Reference

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%