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
- Nil Coalescing
- 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-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
- Equal
- Not
- Less
- Variables Substitution
- Between
- Compound Predicates
- String BEGINSWITH
- String CONTAINS
- String ENDSWITH
- String LIKE
- String MATCHES
- IN
- Block Predicate
- 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
- If Case (Enumeration Case Pattern)
- 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
- 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
- Using methods with NSError
- 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
- 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
- Adding and Removing Observer for a Notification
- Posting a Notification
- Executing
- Contexts
- Observable Properties
- Handle observing
- 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
- 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
- Filtering
- Reducing
- Mapping
- FlatMap
- Combining uses
- Scheduled Timer on the current NSRunLoop
- Scheduled Timer With Repetition
- Scheduling Timers Manually
- Scheduling Timers Manually With Fire Date
- Firing Timers Manually
- 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
- Shared Instance
- Bool Values
- Integer Values
- Float Values
- Double Values
- String Value
- Array Value
- Dictionary Value
- Data Value
- URL Value
- Removing Defaults
- Synchronyze
- Notifications
- 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