✦ Ruta Oficial AppCloud👥 905.000 desarrolladores
Swift
This cheat sheet provides examples of using Swift that cover basic Swift knowledge, control flow etc.
Getting Started
11 ejemplos#Variable
#Type annotations
#Arithmetic operators
#String interpolation
#Multi-line string
#Code Comments
#Form a tuple
#Decompose tuple
#Special comment syntax (MARK)
#Special comment syntax (TODO)
#Special Comment Syntax (FIXME)
Variable
6 ejemplos#Variable declaration
#Constants
#Computed variables (get and set)
#willSet
#didSet
#willSet and didSet
Conditions
16 ejemplos#if statement
#else statement
#else if statement
#Comparison Operators
#Range Operators
#Ternary conditional operator
#switch statement
#switch statement: interval matching
#switch statement: composite case
#switch statement: where clause
#Logical Operators
#Logical Operators &&
#Logical operators ||
#Combined Logical Operators
#Control the order of execution
#Simple guards
cycle
7 ejemplos#scope
#stride() function
#for-in loop
#continue keyword
#break keyword
#Use underscores
#while loop
Arrays and collections
22 ejemplos#Array
#.count property
#index
#Initialize with array literal
#Initialize with default value
#.append() method and += operator
#.insert() and .remove() methods
#Iterate over an array
#Collection (Set)
#Empty collection (Set)
#Populate the collection
#.insert()
#.remove() and .removeAll() methods
#.contains()
#.isEmpty property
#Iterate over a collection
#.isEmpty property
#.count property
#.intersection() Intersection
#.union()
#.symmetricDifference() Symmetric difference
#.subtracting() Subtraction
dictionary
12 ejemplos#Base Dictionary
#Keys
#Type Consistency
#Initialize and populate the dictionary
#Initialize an empty dictionary
#add to dictionary
#Delete key-value pair
#Modify the key-value pair
#.isEmpty property
#.count property
#Assigning values to variables
#Traversing the dictionary
function
12 ejemplos#Basic functions
#Call functions
#return value
#Multiple parameters
#Omit parameter labels
#return multiple values
#Parameters & Arguments
#Implicit return
#Default parameters
#Input and output parameters
#variable parameter
#Optional parameters
structure
7 ejemplos#Structure Creation
#Default property values
#Structural instance creation
#init() method
#Check type
#Mutation method (mutating)
#Structural methods
class
7 ejemplos#reference type (class)
#instance of the class
#init() method
#Class Attributes
#Inherit
#Example
#This is an example of a struct definition and a class definition
Enumerate
8 ejemplos#Define the enumeration
#Switch statement
#CaseIterable
#Original value
#Related values
#instance method
#Initialize from primitive value
#Computed properties
Extensions
11 ejemplos#What are extensions?
#Why use extensions?
#Extension syntax
#Computed properties
#Methods
#Mutating methods
#Initializers
#Subscripts
#Protocol extensions
#Constraints for extensions
#Organizing code with extensions
Generics
9 ejemplos#What are generics?
#Why use generics?
#Type parameters
#Generic Data Structures
#Generic Functions
#Constraints on Generics
#Associated Types
#Generic Protocols
#Generic Typealiases
¿Listo para practicar con ?
Aplica esta sintaxis resolviendo desafíos interactivos con consola en vivo en nuestros 6 módulos de aprendizaje.