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 :)
- Constants
- Variables
- Type Annotations
- Emoji Names
- Printing
- Comments
- Integer
- Float
- Double
- Boolean
- String
- Tuples
- Type aliases
- Converting types
- 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
- Declaration
- Unwrapping
- Can set nil
- Testing
- Optional Binding
- 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
- 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
- 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
- Empty Dictionary
- Dictionary with a Dictionary Literal
- Dictionary Count
- Check if it is Empty
- Modifying a Dictionary
- Iterating Over a Dictionary
- Get Dictionary List
- 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
- 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
- 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
- Enumeration Syntax
- Matching Enumeration Values with a Switch Statement
- Associated Values
- Raw Values
- Implicitly Assigned Raw Values
- Initializing from a Raw Value
- Recursive Enumerations
- Definition Syntax
- Structure Instances
- Accessing Properties
- Structures Are Value Types
- Methods
- 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
- Representing Errors
- Propagating Errors Using Throwing Functions
- Handling Errors Using Do-Catch
- Converting Errors to Optional Values
- Disabling Error Propagation
- Specifying Cleanup Actions
- Defining a Class Hierarchy for Type Casting
- Checking Type
- Downcasting
- Type Casting for AnyObject
- Type Casting for Any
- Nested Types in Action
- Referring to Nested Types
- Computed Properties
- Initializers
- Methods
- Mutating Instance Methods
- Subscripts
- Nested Types
- 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
- 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 Syntax
- Custom Types
- Enumeration Types
- Subclassing
- Constants, Variables, Properties, and Subscripts
- 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
- Adding and Removing Observer for a Notification
- Posting a Notification
- Executing
- JSON Data
- Serialization
- Creating a Manager
- Executing and Canceling
- Block Operation
- Priority and Quality of Service
- Custom Operation
- Main and Current Queue
- Operation Queue
- Cancelling Operations
- Dependencies
- 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