├── .DS_Store ├── .gitattributes ├── 001-VariablesConstantes ├── .DS_Store ├── 01-001-Variables.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 01-002-Numeros.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 01-003-Booleans.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── 01-004-Error.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 002-Operadores ├── .DS_Store ├── 02-001-Aritmetica.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 02-002-Comparacion.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 02-003-Rangos.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── 02-004-Logica.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 003-Strings ├── .DS_Store ├── 03-001-Strings.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 03-002-Unicode.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 03-003-Substring.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 004-Collecciones ├── .DS_Store ├── 04-001-Arrays.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 04-002-Sets.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 04-003-Dictionaries.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 005-ControlFlow ├── .DS_Store ├── 05-001-For.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 05-002-While.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 05-003-Control.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 05-004-Switch.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 05-005-ControlTransfer.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 05-006-Nominales.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── JuanGabriel.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 006-Funciones ├── .DS_Store ├── 06-001-Funciones.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 06-002-Funciones2.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 06-003-Funciones3.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 007-Closures ├── .DS_Store ├── 07-001-Closures.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 07-002-Closures2.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 07-003-Closures3.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 008-Enumerados ├── .DS_Store ├── 08-001-Enumerados.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 08-002-Enumerados2.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 009-ClassStruct ├── .DS_Store └── 09-001-Clases.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 010-Properties ├── .DS_Store ├── 010-1-StoredProperties.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 010-2-ComputedProperties.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 010-3-Observers.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 010-4-TypeProperties.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ └── contents.xcworkspacedata │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 011-Methods ├── .DS_Store ├── 011-1-InstanceMethods.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 011-2-Mutating.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 011-3-TypeMethods.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ └── contents.xcworkspacedata │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 012-Subscripts ├── .DS_Store ├── 012-1-Subscripts.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 012-2-Matrix.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 013-Herency ├── .DS_Store └── 013-1-Garage.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 014-Inits ├── .DS_Store ├── 014.1-Initialization.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── 014.2-DefaultInits.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 014.3-DesignatedConvenience.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 014.4-FoodSample.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 014.5-FailableInits.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── 014.6-RequiredInits.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 014.7-Deinit.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 015-Optionals ├── .DS_Store ├── 015.1-OptionalChaining.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 015.2-MultilayerOptional.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 016-Errors ├── .DS_Store └── 016.1-ErrorHandling.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ └── JuanGabriel.xcuserdatad │ └── UserInterfaceState.xcuserstate ├── 017-Castings ├── .DS_Store ├── 017-1-Castings.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 017-2-AnyObjects.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 018-NestedTypes ├── .DS_Store └── 018-Blackjack.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 019-Extensions ├── .DS_Store ├── 019-01-Extensions.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 019-02-ExtensionInits.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 019-03-ExtensionMethods.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 019-04-ExtensionSubscripts.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 019-05-ExtensionNested.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ └── contents.xcworkspacedata │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 020-Protocols ├── .DS_Store ├── 020-01-Protocols.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 020-02-ProtocolProperties.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 020-03-ProtocolMethods.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 020-04-ProtocolInits.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 020-05-ProtocolTypes.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 020-06-ProtocolComparison.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 020-07-ProtocolConformance.playground │ ├── Contents.swift │ ├── contents.xcplayground │ └── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── 020-08-OptionalProtocols.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 020-09-ProtocolExtension.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 021-Generics ├── .DS_Store ├── 021-01-Generics.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 021-02-GenericsTypes.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 021-03-GenericsConstraints.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 021-04-AssociatedTypes.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 021-05-AssociatedTypes2.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ └── contents.xcworkspacedata │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 022-ARC ├── .DS_Store ├── 022-01-ARC.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 022-02-ARC-Cycles.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 022-03-ARC-Unowned.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── 022-04-ARC-UnownedRefs2.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── juangabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 022-05-ARC-Closures.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── JuanGabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 023-MemoryManagement ├── .DS_Store ├── 023-01-MemoryAccess.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── JuanGabriel.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ ├── timeline.xctimeline │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 023-02-MemoryAccessProperties.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 024-AccessControl ├── .DS_Store ├── 024-01-AccessControl.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── 024-02-AccessControl2.playground │ ├── Contents.swift │ ├── contents.xcplayground │ ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── 025-AdvancedOperators ├── .DS_Store ├── 025-01-BitwiseOperators.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 025-02-Overflow.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist ├── 025-03-Precedence-Associativity.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── juangabriel.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── juangabriel.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── 025-04-Method-Operators.playground ├── Contents.swift ├── contents.xcplayground ├── playground.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── juangabriel.xcuserdatad │ └── UserInterfaceState.xcuserstate └── xcuserdata └── juangabriel.xcuserdatad └── xcschemes └── xcschememanagement.plist /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /001-VariablesConstantes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/001-VariablesConstantes/.DS_Store -------------------------------------------------------------------------------- /001-VariablesConstantes/01-001-Variables.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Variables: valores que van a cambiar 6 | //Constantes: valores de código que nunca cambiarán 7 | let maximumNumberOfLogins = 10 8 | 9 | var currentLoginAttempt = 0 10 | 11 | var x = 0.0, y = 0.0, z = 0.0 12 | 13 | //Variable que indica el mensaje de bienvenida a la app 14 | var welcomeMessage: String 15 | 16 | welcomeMessage = "Hola" 17 | 18 | print(welcomeMessage) 19 | 20 | welcomeMessage = "Bonjour" 21 | 22 | print("Me acaban de saludar diciendo: \(welcomeMessage)") 23 | 24 | //print([1,2,3], separator: "-", terminator: ".") 25 | 26 | let language = "Swift" 27 | 28 | var red, green, blue: Double 29 | 30 | let π = 3.14159265 31 | 32 | //let ☠️ = "muerte" 33 | 34 | let 🐶🐮 = "perrovaca" 35 | 36 | 🐶🐮 37 | 38 | let a3 = 45 39 | 40 | let cat = "🐱"; print(cat) 41 | 42 | /* 43 | Esto es un comentario 44 | que ocupa varias lineas 45 | de código en Swift. 46 | */ 47 | 48 | /* 49 | Esto es la primera linea del comentario. 50 | /* 51 | Esto es un segundo comentario, anidado al primero. 52 | */ 53 | Esto es el comentario qeu finaliza el multilinea. 54 | */ 55 | 56 | 57 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-001-Variables.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-001-Variables.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-001-Variables.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/001-VariablesConstantes/01-001-Variables.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /001-VariablesConstantes/01-001-Variables.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 01-001-Variables (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-002-Numeros.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-002-Numeros.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-002-Numeros.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/001-VariablesConstantes/01-002-Numeros.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /001-VariablesConstantes/01-002-Numeros.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 01-002-Numeros (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-003-Booleans.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-003-Booleans.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-003-Booleans.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/001-VariablesConstantes/01-003-Booleans.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /001-VariablesConstantes/01-004-Error.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Errores 6 | func canThrowError() throws{ 7 | 8 | } 9 | 10 | 11 | 12 | do{ 13 | try canThrowError() 14 | //Si no ha lanzado error, el código sigue por aquí 15 | } catch{ 16 | //Si hay un error, entraremos en la zona del catch 17 | } 18 | 19 | 20 | 21 | 22 | func makeASandwich() throws { 23 | 24 | } 25 | 26 | func eatASandwich(){ 27 | 28 | } 29 | 30 | func washTheDishes(){ 31 | 32 | } 33 | 34 | func buyIngredients(){ 35 | 36 | } 37 | 38 | 39 | do{ 40 | try makeASandwich() 41 | eatASandwich() 42 | } catch { 43 | //No tenemos platos limpios 44 | washTheDishes() 45 | } catch { 46 | //NO tengo ingredientes para el sandwich 47 | buyIngredients() 48 | } 49 | 50 | 51 | //Aserciones y precondiciones 52 | let age = -8 53 | //assert(age>=0, "Una persona no puede tener edad negativa") 54 | //assert(age>=0) 55 | 56 | /*if age > 10 { 57 | print("Puedes subir a la montaña rusa") 58 | } else if age > 0 { 59 | print("Eres muy pequeño para la montaña rusa, mejor súbete a los caballitos") 60 | } else { 61 | assertionFailure("Una persona no puede tener edad negativa") 62 | }*/ 63 | 64 | let index = -5 65 | precondition(index>=0, "Los índices deben ser mayores o iguales a cero!") 66 | //preconditionFailure("") 67 | 68 | 69 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-004-Error.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-004-Error.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /001-VariablesConstantes/01-004-Error.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/001-VariablesConstantes/01-004-Error.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /001-VariablesConstantes/01-004-Error.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 01-004-Error (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /002-Operadores/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/002-Operadores/.DS_Store -------------------------------------------------------------------------------- /002-Operadores/02-001-Aritmetica.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Asignación 6 | let b = 12 7 | var a = 4 8 | print(a) 9 | a = b 10 | print(a) 11 | 12 | 13 | 14 | let (x,y) = (1, 5) 15 | print("x = \(x), y = \(y)") 16 | 17 | /* 18 | if x = y { 19 | //Esto no es válido, ya que x = y no devuelve un valor, solamente asigna 20 | } 21 | */ 22 | 23 | 24 | //Aritmética básica: +, -, *, /, % 25 | 2+5 26 | 3-2 27 | 3*4 28 | 10.0/2.5 29 | 30 | 34&+52 31 | 32 | "hola, " + "mundo" 33 | 34 | 35 | 5/2 36 | 5.0/2.0 37 | 5%2 38 | //9 = 4*q + r, q = 9/4, r = 9%4 r = 0,1,2,3 39 | 9%4 40 | //9 = (4*2) + 1 41 | -9%4 42 | //-9 = (4*-2) -1 (r = -3,-2,-1,0) 43 | 9 % -4 44 | //a%b == a%-b 45 | 46 | 47 | //Operador unario 48 | let two = 2 49 | let minusTwo = -two 50 | let plusTwo = -minusTwo 51 | 52 | let minusSix = -6 53 | let alsoMinusSix = +minusSix //= minusSix, = +minusSix 54 | 55 | 56 | //Operador compuesto: asignar y operar 57 | var a1 = 3 58 | a1 += 2 //a1 = a1 + 2 = 3 + 2 = 5 59 | a1 -= 3 60 | a1 *= 4 61 | a1 /= 2 62 | a1 %= 3 63 | 64 | var step = 0 65 | step += 2 66 | step += 2 67 | step += 2 68 | 69 | -------------------------------------------------------------------------------- /002-Operadores/02-001-Aritmetica.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /002-Operadores/02-001-Aritmetica.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /002-Operadores/02-001-Aritmetica.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/002-Operadores/02-001-Aritmetica.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /002-Operadores/02-001-Aritmetica.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 02-001-Aritmetica (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /002-Operadores/02-002-Comparacion.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Comparación 6 | /* 7 | Igual (a == b) 8 | No igual (a != b) 9 | Mayor que (a > b) 10 | Menor que (a < b) 11 | Mayor o igual que (a >= b) 12 | Menor o igual que (a <= b) 13 | */ 14 | 15 | 1 == 1 16 | 1 != 2 17 | 2 > 1 18 | 1 < 2 19 | 1 >= 1 20 | 2 <= 1 21 | 22 | 23 | let name = "JB" 24 | 25 | if name == "JB" { 26 | print("Hola, JB! Hacia tiempo que no nos veíamos") 27 | } else { 28 | print("Lo siento \(name), pero no se quien eres") 29 | } 30 | 31 | 32 | (1, "Juan Gabriel")<(2,"Mar") 33 | (3, "Juan Gabriel")<(3,"Mar") 34 | (4, "JB") == (4, "JB") 35 | 36 | //Operador ternario 37 | //pregunta ? si cierto : si falsa 38 | /* if pregunta { 39 | si cierto 40 | } else { 41 | si falsa 42 | } 43 | */ 44 | 45 | let myWallet = 20 46 | let isPayday = true 47 | //let newWallet = myWallet + (isPayday ? 50 : 0) 48 | let newWallet: Int 49 | 50 | if isPayday{ 51 | newWallet = myWallet + 50 52 | } else { 53 | newWallet = myWallet 54 | } 55 | 56 | newWallet 57 | 58 | 59 | //nil (a ?? b) 60 | // a != nil ? a! : b 61 | 62 | let defaultColor = "green" 63 | 64 | var userSelectedColor: String? 65 | 66 | var colorToUse = userSelectedColor ?? defaultColor 67 | 68 | print(colorToUse) 69 | -------------------------------------------------------------------------------- /002-Operadores/02-002-Comparacion.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /002-Operadores/02-002-Comparacion.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /002-Operadores/02-002-Comparacion.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/002-Operadores/02-002-Comparacion.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /002-Operadores/02-002-Comparacion.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 02-002-Comparacion (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /002-Operadores/02-003-Rangos.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Rangos 6 | //Rangos cerrados (a...b) -> a <= x <= b 7 | 8 | for index in 1...10 { 9 | print("\(index) x 5 = \(index*5)") 10 | } 11 | 12 | //Rangos semiabiertos (a.. a <= x < b 13 | let names = ["Juan Gabriel", "Mar", "María", "Juanjo", "Antonia", "Carmen"] 14 | let count = names.count 15 | for i in 0.. 100{ 40 | break 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /002-Operadores/02-003-Rangos.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /002-Operadores/02-003-Rangos.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /002-Operadores/02-003-Rangos.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/002-Operadores/02-003-Rangos.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /002-Operadores/02-004-Logica.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Lógica 6 | 7 | //NOT !a 8 | 9 | let allowedEntry = false 10 | 11 | if !allowedEntry { 12 | print("Acceso denegado") 13 | } else { 14 | print("Puedes pasar") 15 | } 16 | 17 | //AND a && b 18 | 19 | let hasDoorKey = false 20 | 21 | let knowsPassword = true 22 | 23 | let passRetinaScan = false 24 | 25 | let isAdmin = true 26 | 27 | if hasDoorKey && knowsPassword { 28 | print("Bienvenido a la sede de Frogames") 29 | } else { 30 | print("Cuidado, un intruso! Acceso Denegado!") 31 | } 32 | 33 | //OR a || b 34 | 35 | if hasDoorKey || knowsPassword { 36 | print("Enhorabuena, has entrado") 37 | } else { 38 | print("Ni contraseña ni llave? Estás despedido!!") 39 | } 40 | 41 | 42 | if (knowsPassword && passRetinaScan) || ((hasDoorKey) || (isAdmin)) { 43 | print("Bienvenido") 44 | } else { 45 | print("Acceso denegado") 46 | } 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /002-Operadores/02-004-Logica.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /002-Operadores/02-004-Logica.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /002-Operadores/02-004-Logica.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/002-Operadores/02-004-Logica.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /002-Operadores/02-004-Logica.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 02-004-Logica (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /003-Strings/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/003-Strings/.DS_Store -------------------------------------------------------------------------------- /003-Strings/03-001-Strings.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Strings 6 | let myString = "Hola, esto es un String" 7 | 8 | let frase = """ 9 | 10 | En un lugar de \"""La Mancha\"\"\", 11 | de cuyo nombre no quiero acordarme, 12 | 13 | no ha mucho tiempo que vivía 14 | un hidalgo de los de lanza en astillero... 15 | 16 | """ 17 | 18 | print(frase) 19 | 20 | let singleLineString = "Esto es un string de una línea" 21 | let multilineString = """ 22 | Esto también es un string de una línea 23 | """ 24 | 25 | var emptyString = "" 26 | var otherEmptyString = String() 27 | 28 | if emptyString.isEmpty { 29 | print("String vacío") 30 | } 31 | 32 | var title = "Harry Potter" 33 | title += " y la piedra filosofal" 34 | print(title) 35 | 36 | /*let newTitle = "Harry Potter" 37 | newTitle += " y la cámara de los secretos" 38 | */ 39 | 40 | let newTitle = title 41 | 42 | title = "El señor de los anillos" 43 | 44 | newTitle 45 | 46 | 47 | 48 | //Caracteres 49 | for character in "Perrito 🐶" { 50 | print(character) 51 | } 52 | 53 | let questionMark : Character = "?" 54 | 55 | let dogArray: [Character] = ["P", "e", "r", "r", "o", "🐶"] 56 | let dogString = String(dogArray) 57 | print(dogString) 58 | 59 | let s1 = "Hola" 60 | let s2 = " Mundo" 61 | var welcome = s1 + s2 62 | welcome += " soy JB" 63 | welcome.append(questionMark) 64 | print(welcome) 65 | 66 | let multiplo = 3 67 | let message = "\(multiplo) x 2.5 = \(Double(multiplo) * 2.5)" 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /003-Strings/03-001-Strings.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /003-Strings/03-001-Strings.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /003-Strings/03-001-Strings.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/003-Strings/03-001-Strings.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /003-Strings/03-001-Strings.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 03-001-Strings (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /003-Strings/03-002-Unicode.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Unicode 6 | 7 | let a = "a" // U+0061 8 | let pollito = "🐥" //U+1F425 9 | 10 | //La barra de escape \ 11 | let null = "\0" 12 | let backslash = "\\" 13 | let tab = "\t" 14 | let intro = "\n" 15 | let carro = "\r" 16 | let comilla = "\"" 17 | print(intro) 18 | 19 | print("\u{24}") 20 | print("\u{2665}") 21 | print("\u{1F496}") 22 | 23 | 24 | let char = "é" 25 | print("\u{00e9}") 26 | print("\u{0065}") 27 | print("\u{0301}") 28 | let newChar: Character = "\u{65}\u{301}" 29 | 30 | let koreanExample: Character = "\u{D55C}" 31 | let decomposedExample: Character = "\u{1112}\u{1161}\u{11AB}" 32 | 33 | print("\u{65}\u{301}\u{20DD}") 34 | 35 | let patriots : Character = "\u{1F1FA}\u{1F1F8}" 36 | print(patriots) 37 | 38 | let animals = "Perro 🐶, Gato 🐱, Cerdo 🐷, Pollito 🐥" 39 | 40 | print("La granja de pepito tiene \(animals.count) caracteres") 41 | 42 | var coffee = "cafe" 43 | coffee += "\u{301}" 44 | print("\(coffee) tiene \(coffee.count) caracteres") 45 | 46 | 47 | -------------------------------------------------------------------------------- /003-Strings/03-002-Unicode.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /003-Strings/03-002-Unicode.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /003-Strings/03-002-Unicode.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/003-Strings/03-002-Unicode.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /003-Strings/03-002-Unicode.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 03-002-Unicode (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /003-Strings/03-003-Substring.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /003-Strings/03-003-Substring.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /003-Strings/03-003-Substring.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/003-Strings/03-003-Substring.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /003-Strings/03-003-Substring.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /003-Strings/03-003-Substring.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 03-003-Substring (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /004-Collecciones/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/004-Collecciones/.DS_Store -------------------------------------------------------------------------------- /004-Collecciones/04-001-Arrays.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /004-Collecciones/04-001-Arrays.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /004-Collecciones/04-001-Arrays.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/004-Collecciones/04-001-Arrays.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /004-Collecciones/04-001-Arrays.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /004-Collecciones/04-001-Arrays.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 04-001-Arrays (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /004-Collecciones/04-002-Sets.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /004-Collecciones/04-002-Sets.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /004-Collecciones/04-002-Sets.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/004-Collecciones/04-002-Sets.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /004-Collecciones/04-002-Sets.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /004-Collecciones/04-002-Sets.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 04-002-Sets (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /004-Collecciones/04-003-Dictionaries.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /004-Collecciones/04-003-Dictionaries.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /004-Collecciones/04-003-Dictionaries.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/004-Collecciones/04-003-Dictionaries.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /004-Collecciones/04-003-Dictionaries.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /004-Collecciones/04-003-Dictionaries.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 04-003-Dictionaries (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /005-ControlFlow/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/.DS_Store -------------------------------------------------------------------------------- /005-ControlFlow/05-001-For.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Bucle For-in 6 | let dishes = ["Pizza", "Hamburguesa", "Ensalada", "Patatas Fritas"] 7 | for dish in dishes { 8 | print("Hoy de menú tenemos \(dish)") 9 | } 10 | 11 | 12 | let animals = ["araña": 8, "perro": 4, "hormiga": 6, "canguro":2] 13 | for (animalName, numberOfLegs) in animals { 14 | print("El animal \(animalName) tiene \(numberOfLegs) patas") 15 | } 16 | 17 | 18 | 19 | for i in 1...10{ // let i = 10 20 | print("3x\(i)=\(3*i)") 21 | } 22 | 23 | //2*2*2...*2 10 veces 24 | 25 | let base = 2 26 | let power = 10 27 | var answer = 1 28 | for _ in 1...10 { 29 | answer *= 2 30 | } 31 | 32 | print("\(base) elevado a \(power) es igual a \(answer)") 33 | 34 | let seconds = 60 35 | 36 | for tick in 0.. 2 | 3 | 4 | -------------------------------------------------------------------------------- /005-ControlFlow/05-001-For.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /005-ControlFlow/05-001-For.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/05-001-For.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /005-ControlFlow/05-001-For.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /005-ControlFlow/05-001-For.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 05-001-For (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /005-ControlFlow/05-002-While.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Bucle While 6 | /* 7 | while condicion { 8 | código a ejecutar 9 | } 10 | */ 11 | 12 | let goal = 25 13 | var board = [Int](repeating:0, count: goal+1) 14 | 15 | board[03] = +08; board[06] = +11; board[09] = +09; board[10] = +02 16 | board[14] = -10; board[19] = -11; board[22] = -02; board[24] = -08 17 | 18 | var square = 0 19 | var dice = 0 20 | while square < goal { 21 | //Lanzar dado 22 | dice += 1 23 | if dice == 7 { 24 | dice = 1 25 | } 26 | 27 | square += dice 28 | 29 | if square < board.count { 30 | square += board[square] 31 | } 32 | } 33 | 34 | 35 | print("Game Over") 36 | 37 | 38 | /* 39 | repeat { 40 | código a ejecutar 41 | } while condicion 42 | */ 43 | 44 | square = 0 45 | dice = 0 46 | 47 | repeat { 48 | square += board[square] 49 | 50 | dice += 1 51 | 52 | if dice == 7 { dice = 1 } 53 | 54 | square += dice 55 | 56 | } while square < goal 57 | 58 | print("Game Over") 59 | -------------------------------------------------------------------------------- /005-ControlFlow/05-002-While.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /005-ControlFlow/05-002-While.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /005-ControlFlow/05-002-While.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/05-002-While.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /005-ControlFlow/05-002-While.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /005-ControlFlow/05-002-While.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 05-002-While (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /005-ControlFlow/05-003-Control.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //If Else 6 | /* 7 | if condicion { 8 | código a ejecutar si la condición es cierta 9 | } else { 10 | código a ejecutar si la condición es falsa 11 | } 12 | */ 13 | var isRaining = true 14 | if isRaining { 15 | print("Coge un paraguas que llueve!") 16 | } 17 | 18 | var temperature = 25 19 | if temperature < 12 { 20 | print("Abrígate que hace frío") 21 | } else { 22 | print("No hace falta que cojas abrigo, pilla mejor una camiseta") 23 | } 24 | 25 | 26 | if temperature < 12 { 27 | print("Coge el abrigo") 28 | } else if temperature >= 30 { 29 | print("Coge el bañador") 30 | } else { 31 | print("Se está bien, podemos ir en camiseta") 32 | } 33 | 34 | 35 | if temperature < 12 { 36 | print("Coge el abrigo") 37 | } else if temperature >= 30 { 38 | print("Coge el bañador") 39 | } 40 | 41 | //Switch - case 42 | -------------------------------------------------------------------------------- /005-ControlFlow/05-003-Control.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /005-ControlFlow/05-003-Control.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /005-ControlFlow/05-003-Control.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/05-003-Control.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /005-ControlFlow/05-003-Control.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /005-ControlFlow/05-003-Control.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 05-003-Control (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /005-ControlFlow/05-004-Switch.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /005-ControlFlow/05-004-Switch.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /005-ControlFlow/05-004-Switch.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/05-004-Switch.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /005-ControlFlow/05-004-Switch.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /005-ControlFlow/05-004-Switch.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 05-004-Switch (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /005-ControlFlow/05-005-ControlTransfer.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Control Transfer 6 | //Return -> Funciones 7 | 8 | //Throw -> Errores 9 | 10 | //Continue 11 | let input = "el perro de san roque no tiene rabo" 12 | var output = "" 13 | let charactersToRemove : [Character] = ["a", "e", "i", "o", "u", " "] 14 | 15 | for character in input { 16 | if charactersToRemove.contains(character){ 17 | continue 18 | } else { 19 | output.append(character) 20 | } 21 | } 22 | print(output) 23 | 24 | //Break 25 | var int = 1 26 | while int < 100 { 27 | int += 1 28 | if int >= 10 { 29 | break 30 | } 31 | } 32 | print(int) 33 | 34 | let number : Character = "三" 35 | var possibleValue : Int? 36 | switch number { 37 | case "1", "一": 38 | possibleValue = 1 39 | case "2", "二": 40 | possibleValue = 2 41 | case "3", "三": 42 | possibleValue = 3 43 | case "4", "四": 44 | possibleValue = 4 45 | default: 46 | break 47 | } 48 | 49 | if let integerValue = possibleValue { 50 | print("El valor entero de \(number) es \(integerValue)") 51 | } else { 52 | print("No se qué número corresponde a \(number)") 53 | } 54 | 55 | //Fallthrough 56 | 57 | let integerToDescribe = 7 58 | var description = "El número \(integerToDescribe) es" 59 | switch integerToDescribe { 60 | case 2,3,5,7,11,13,14,19,23: 61 | description += " primo, y además" 62 | fallthrough 63 | default: 64 | description += " entero" 65 | } 66 | 67 | print(description) 68 | 69 | -------------------------------------------------------------------------------- /005-ControlFlow/05-005-ControlTransfer.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /005-ControlFlow/05-005-ControlTransfer.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /005-ControlFlow/05-005-ControlTransfer.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/05-005-ControlTransfer.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /005-ControlFlow/05-005-ControlTransfer.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /005-ControlFlow/05-005-ControlTransfer.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 05-005-ControlTransfer (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /005-ControlFlow/05-006-Nominales.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /005-ControlFlow/05-006-Nominales.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /005-ControlFlow/05-006-Nominales.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/005-ControlFlow/05-006-Nominales.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /006-Funciones/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/006-Funciones/.DS_Store -------------------------------------------------------------------------------- /006-Funciones/06-001-Funciones.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /006-Funciones/06-001-Funciones.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /006-Funciones/06-001-Funciones.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/006-Funciones/06-001-Funciones.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /006-Funciones/06-001-Funciones.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /006-Funciones/06-001-Funciones.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 06-001-Funciones (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /006-Funciones/06-002-Funciones2.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /006-Funciones/06-002-Funciones2.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /006-Funciones/06-002-Funciones2.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/006-Funciones/06-002-Funciones2.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /006-Funciones/06-002-Funciones2.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /006-Funciones/06-002-Funciones2.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 06-002-Funciones2 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /006-Funciones/06-003-Funciones3.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /006-Funciones/06-003-Funciones3.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /006-Funciones/06-003-Funciones3.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/006-Funciones/06-003-Funciones3.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /006-Funciones/06-003-Funciones3.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /006-Funciones/06-003-Funciones3.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 06-003-Funciones3 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /007-Closures/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/007-Closures/.DS_Store -------------------------------------------------------------------------------- /007-Closures/07-001-Closures.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Closures 6 | /* 7 | - Funciones globales que tienen un nombre y no capturan ningún valor 8 | - Funciones anidadas con un nombre que pueden capturar valores de la función englobante 9 | - Funciones sin nombre escrita en un contexto dentro de otra función que puede capturar valores del contexto que la rodea. 10 | 11 | 12 | - Inferir un parámetro y devolver un valor de retorno en un contexto 13 | - Hacer un retorno impícito de una expresión simple 14 | - Nomenclatura simplificada (shorthand) 15 | - Sintaxis de closure para funciones específicas 16 | */ 17 | 18 | let people = ["Juan Gabriel", "María", "Antonia", "Margarita", "Juan José", "Carmen", "Ricardo"] 19 | 20 | func sortBackward(_ s1: String, _ s2: String) -> Bool { 21 | return s1 > s2 22 | } 23 | 24 | var reversedPeople = people.sorted(by: sortBackward) 25 | print(reversedPeople) 26 | 27 | /* Sintaxis de Closures 28 | { (parametros) -> valor de retorno in 29 | //código del closure 30 | } 31 | */ 32 | 33 | reversedPeople = people.sorted(by: { (s1: String, s2: String) -> Bool in return s1 > s2 }) 34 | 35 | reversedPeople = people.sorted(by: { s1, s2 in return s1 > s2 } ) 36 | 37 | reversedPeople = people.sorted(by: { s1, s2 in s1 > s2 }) 38 | 39 | reversedPeople = people.sorted(by: { $0 > $1 }) 40 | 41 | reversedPeople = people.sorted(by: >) 42 | -------------------------------------------------------------------------------- /007-Closures/07-001-Closures.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /007-Closures/07-001-Closures.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /007-Closures/07-001-Closures.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/007-Closures/07-001-Closures.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /007-Closures/07-001-Closures.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /007-Closures/07-001-Closures.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 07-001-Closures (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /007-Closures/07-002-Closures2.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /007-Closures/07-002-Closures2.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /007-Closures/07-002-Closures2.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/007-Closures/07-002-Closures2.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /007-Closures/07-002-Closures2.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /007-Closures/07-002-Closures2.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 07-002-Closures2 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /007-Closures/07-003-Closures3.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /007-Closures/07-003-Closures3.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /007-Closures/07-003-Closures3.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/007-Closures/07-003-Closures3.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /007-Closures/07-003-Closures3.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /007-Closures/07-003-Closures3.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 07-003-Closures3 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /008-Enumerados/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/008-Enumerados/.DS_Store -------------------------------------------------------------------------------- /008-Enumerados/08-001-Enumerados.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | //Enumerados 6 | enum NombreDelEnumerado { 7 | //Aquí decalaríamos los posibles valores del enumerado 8 | } 9 | 10 | 11 | enum CompassPoint { 12 | case north 13 | case south 14 | case east 15 | case west 16 | } 17 | 18 | 19 | enum Planet { 20 | case mercurio, venus, tierra, marte, jupiter, saturno, urano, neptuno 21 | } 22 | 23 | 24 | var directionToGo = CompassPoint.north 25 | directionToGo = .west 26 | 27 | var planet : Planet = .tierra 28 | 29 | 30 | switch directionToGo { 31 | case .north: 32 | print("Hace mucho frio en el norte") 33 | case .south: 34 | print("Los alemanes veranean en el sur") 35 | case .east: 36 | print("Cuidado con los orcos del este!") 37 | case .west: 38 | print("Allá, al oeste es territorio desconocido") 39 | } 40 | 41 | switch planet { 42 | case .tierra: 43 | print("Se vive bien aquí en la tierra") 44 | default: 45 | print("No se ha detectado vida aún en este planeta") 46 | } 47 | 48 | 49 | enum Barcode { 50 | case upc(Int, Int, Int, Int) 51 | case qrCode(String) 52 | } 53 | 54 | var productBarcode = Barcode.upc(6, 71680, 01362, 4) 55 | print(productBarcode) 56 | 57 | productBarcode = .qrCode("A68JFJAMXO·(JF(KGj/H") 58 | print(productBarcode) 59 | 60 | switch productBarcode { 61 | case let .upc(numberSystem, manufacturer, product, check): 62 | print("UPC: \(numberSystem), \(manufacturer), \(product), \(check)") 63 | case .qrCode(let productCode): 64 | print("QR Code: \(productCode)") 65 | } 66 | -------------------------------------------------------------------------------- /008-Enumerados/08-001-Enumerados.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /008-Enumerados/08-001-Enumerados.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /008-Enumerados/08-001-Enumerados.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/008-Enumerados/08-001-Enumerados.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /008-Enumerados/08-001-Enumerados.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /008-Enumerados/08-001-Enumerados.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 08-001-Enumerados (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /008-Enumerados/08-002-Enumerados2.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /008-Enumerados/08-002-Enumerados2.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /008-Enumerados/08-002-Enumerados2.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/008-Enumerados/08-002-Enumerados2.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /008-Enumerados/08-002-Enumerados2.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /008-Enumerados/08-002-Enumerados2.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 08-002-Enumerados2 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /009-ClassStruct/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/009-ClassStruct/.DS_Store -------------------------------------------------------------------------------- /009-ClassStruct/09-001-Clases.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /009-ClassStruct/09-001-Clases.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /009-ClassStruct/09-001-Clases.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/009-ClassStruct/09-001-Clases.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /009-ClassStruct/09-001-Clases.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /009-ClassStruct/09-001-Clases.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 09-001-Clases (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /010-Properties/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/010-Properties/.DS_Store -------------------------------------------------------------------------------- /010-Properties/010-1-StoredProperties.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /010-Properties/010-1-StoredProperties.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /010-Properties/010-1-StoredProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/010-Properties/010-1-StoredProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /010-Properties/010-1-StoredProperties.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 010-1-StoredProperties (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /010-Properties/010-2-ComputedProperties.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /010-Properties/010-2-ComputedProperties.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /010-Properties/010-2-ComputedProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/010-Properties/010-2-ComputedProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /010-Properties/010-2-ComputedProperties.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 010-2-ComputedProperties (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /010-Properties/010-3-Observers.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class StepCounter{ 2 | var totalSteps : Int = 0{ 3 | 4 | willSet(newTotalSteps){ 5 | print("Estoy a punto e cambiar totalSteps por \(newTotalSteps)") 6 | } 7 | 8 | didSet{ 9 | if totalSteps > oldValue { 10 | print("Acabamos de sumar \(totalSteps - oldValue) pasos a la cuenta") 11 | } 12 | } 13 | } 14 | } 15 | 16 | 17 | let stepCounter = StepCounter() 18 | stepCounter.totalSteps = 1500 19 | 20 | stepCounter.totalSteps = 3800 21 | 22 | stepCounter.totalSteps = 3800 23 | -------------------------------------------------------------------------------- /010-Properties/010-3-Observers.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /010-Properties/010-3-Observers.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /010-Properties/010-3-Observers.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 010-3-Observers (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /010-Properties/010-4-TypeProperties.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /010-Properties/010-4-TypeProperties.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /010-Properties/010-4-TypeProperties.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 010-4-TypeProperties (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /011-Methods/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/011-Methods/.DS_Store -------------------------------------------------------------------------------- /011-Methods/011-1-InstanceMethods.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class Counter{ 2 | 3 | var counter = 0 4 | 5 | func increment() { 6 | self.counter += 1 7 | } 8 | 9 | func increment(by amount: Int){ 10 | 11 | for i in 0.. Bool{ 43 | return self.x > x 44 | } 45 | } 46 | 47 | let point = Point(x: 4.0, y: -2.0) 48 | 49 | if point.isToTheRightOf(x: 1.5) { 50 | print("El punto está a la derecha de la recta que pasa por 1.5") 51 | } 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /011-Methods/011-1-InstanceMethods.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /011-Methods/011-1-InstanceMethods.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /011-Methods/011-1-InstanceMethods.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/011-Methods/011-1-InstanceMethods.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /011-Methods/011-1-InstanceMethods.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 011-1-InstanceMethods (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /011-Methods/011-2-Mutating.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | struct Point{ 2 | 3 | var x = 0.0, y = 0.0 4 | 5 | mutating func moveBy(x deltaX:Double, y deltaY: Double) { 6 | x += deltaX 7 | y += deltaY 8 | } 9 | } 10 | 11 | var somePoint = Point(x: 1.0, y: 2.0) 12 | somePoint.moveBy(x: 3.0, y: 5.0) 13 | print("El punto se encuentra en (\(somePoint.x), \(somePoint.y))") 14 | 15 | //Las constantes no pueden llamar a métodos mutating 16 | //let fixedPoint = Point(x: 2.0, y: 5.0) 17 | //fixedPoint.moveBy(x: 1.0, y: 1.0) 18 | 19 | 20 | struct Point2{ 21 | var x = 0.0, y = 0.0 22 | 23 | mutating func moveBy(x deltaX: Double, y deltaY: Double){ 24 | self = Point2(x: x + deltaX, y: y + deltaY) 25 | } 26 | 27 | } 28 | 29 | var newPoint = Point2(x: 2.0, y: 5.0) 30 | newPoint.moveBy(x: 1.0, y: 3.0) 31 | 32 | enum CharacterState{ 33 | 34 | case mage, warrior, archer 35 | 36 | mutating func nextCharacter(){ 37 | switch self { 38 | case .mage: 39 | self = .warrior 40 | case .warrior: 41 | self = .archer 42 | case .archer: 43 | self = .mage 44 | } 45 | } 46 | } 47 | 48 | 49 | 50 | var myCharacter = CharacterState.warrior 51 | myCharacter.nextCharacter() 52 | myCharacter.nextCharacter() 53 | myCharacter.nextCharacter() 54 | -------------------------------------------------------------------------------- /011-Methods/011-2-Mutating.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /011-Methods/011-2-Mutating.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /011-Methods/011-2-Mutating.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/011-Methods/011-2-Mutating.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /011-Methods/011-2-Mutating.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 011-2-Mutating (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /011-Methods/011-3-TypeMethods.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /011-Methods/011-3-TypeMethods.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /011-Methods/011-3-TypeMethods.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 011-3-TypeMethods (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /012-Subscripts/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/012-Subscripts/.DS_Store -------------------------------------------------------------------------------- /012-Subscripts/012-1-Subscripts.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class SomeClass{ 2 | subscript(index:Int) -> Int{ 3 | get{ 4 | //Operación de consulta con el índice recibido 5 | return 5 6 | } 7 | set (newValue){ 8 | //Operación de escritura con el índice guardado 9 | } 10 | } 11 | 12 | 13 | subscript(index1:Int, index2:Int)-> Int { 14 | return 5 15 | } 16 | } 17 | 18 | let someInstance = SomeClass() 19 | print(someInstance[37]) 20 | 21 | 22 | 23 | struct TimesTable { 24 | let multiplier : Int 25 | subscript(index:Int) -> Int { 26 | return multiplier * index 27 | } 28 | } 29 | 30 | for j in 1...10 { 31 | 32 | let timesTable = TimesTable(multiplier: j) 33 | print("La tabla de multiplicar de \(j)") 34 | for i in 0...10 { 35 | print("\(i)x3 = \(timesTable[i])")//timesTable[i] = multiplier * i 36 | } 37 | } 38 | 39 | 40 | let collection = [4,6,8,19,43] 41 | collection[2] 42 | 43 | let numberOfLegs = ["pulpo": 8, "perro": 4, "pajaro": 2, "araña": 8] 44 | numberOfLegs["perro"] 45 | -------------------------------------------------------------------------------- /012-Subscripts/012-1-Subscripts.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /012-Subscripts/012-1-Subscripts.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /012-Subscripts/012-1-Subscripts.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 012-1-Subscripts (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /012-Subscripts/012-2-Matrix.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | struct Matrix{ 2 | 3 | let rows: Int, columns: Int 4 | 5 | var grid: [Double] 6 | 7 | init(rows: Int, columns: Int) { 8 | self.rows = rows 9 | self.columns = columns 10 | 11 | grid = Array(repeating: 0.0, count: rows * columns) 12 | } 13 | 14 | func indexIsValid(row: Int, column : Int) -> Bool { 15 | return row>=0 && row < rows && column >= 0 && column < columns 16 | } 17 | 18 | subscript(row: Int, column:Int) -> Double { 19 | get{ 20 | assert(indexIsValid(row: row, column: column), "Indice no disponible en la matriz") 21 | return grid[row*columns + column] 22 | } 23 | set{ 24 | assert(indexIsValid(row: row, column: column), "Indice no disponible en la matriz") 25 | grid[row * columns + column] = newValue 26 | } 27 | } 28 | 29 | 30 | func matrixForm(){ 31 | for i in 0.. 2 | 3 | 4 | -------------------------------------------------------------------------------- /012-Subscripts/012-2-Matrix.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /012-Subscripts/012-2-Matrix.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/012-Subscripts/012-2-Matrix.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /012-Subscripts/012-2-Matrix.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 012-2-Matrix (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /013-Herency/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/013-Herency/.DS_Store -------------------------------------------------------------------------------- /013-Herency/013-1-Garage.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /013-Herency/013-1-Garage.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /013-Herency/013-1-Garage.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/013-Herency/013-1-Garage.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /013-Herency/013-1-Garage.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 013-1-Garage (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /014-Inits/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/.DS_Store -------------------------------------------------------------------------------- /014-Inits/014.1-Initialization.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.1-Initialization.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.1-Initialization.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.1-Initialization.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.2-DefaultInits.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.2-DefaultInits.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.2-DefaultInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.2-DefaultInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.2-DefaultInits.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /014-Inits/014.2-DefaultInits.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 014.2-DefaultInits (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /014-Inits/014.3-DesignatedConvenience.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | /* 2 | init(parameters) { 3 | //Código pertinente de la inicialización... 4 | } 5 | 6 | convenience init(parameters) { 7 | //Código pertinente de la inicialización... 8 | } 9 | */ 10 | 11 | 12 | 13 | class Vehicle { 14 | var numberOfWheels = 0 15 | 16 | var description : String { 17 | return "\(numberOfWheels) ruedas en el vehículo" 18 | } 19 | 20 | } 21 | 22 | let vehicle = Vehicle() 23 | print("Vehículo: \(vehicle.description)") 24 | 25 | 26 | 27 | class Bicycle : Vehicle { 28 | override init() { 29 | super.init() 30 | numberOfWheels = 2 31 | } 32 | } 33 | 34 | let bicycle = Bicycle() 35 | print("Bicicleta: \(bicycle.description)") 36 | -------------------------------------------------------------------------------- /014-Inits/014.3-DesignatedConvenience.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.3-DesignatedConvenience.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.3-DesignatedConvenience.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.3-DesignatedConvenience.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.3-DesignatedConvenience.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 014.3-DesignatedConvenience (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /014-Inits/014.4-FoodSample.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class Food { 2 | var name: String 3 | 4 | init(name: String){ 5 | self.name = name 6 | } 7 | 8 | convenience init(){ 9 | self.init(name: "[Desconocido]") 10 | } 11 | } 12 | 13 | 14 | let singleFood = Food(name: "Jamón York") 15 | singleFood.name 16 | let misteryFood = Food() 17 | misteryFood.name 18 | 19 | 20 | class RecipeIngredient : Food { 21 | 22 | var quantity : Int 23 | 24 | init(name: String, quantity: Int){ 25 | self.quantity = quantity 26 | 27 | super.init(name: name) 28 | } 29 | 30 | override convenience init(name: String){ 31 | self.init(name: name, quantity: 1) 32 | } 33 | } 34 | 35 | 36 | let oneMisteryIngredient = RecipeIngredient() 37 | let oneBacon = RecipeIngredient(name: "Bacon") 38 | let sixEggs = RecipeIngredient(name: "Huevos", quantity: 6) 39 | 40 | 41 | class ShoppingListItem : RecipeIngredient { 42 | var purchased = false 43 | 44 | var description : String { 45 | var output = "\(quantity) x \(name) " 46 | output += (purchased ? "OK" : "X") 47 | return output 48 | } 49 | } 50 | 51 | var breakfastList = [ 52 | ShoppingListItem(), 53 | ShoppingListItem(name: "Bacon"), 54 | ShoppingListItem(name: "Huevos", quantity: 6) 55 | ] 56 | 57 | breakfastList[0].name = "Zumo de naranja" 58 | breakfastList[0].quantity = 1 59 | breakfastList[0].purchased = true 60 | 61 | for item in breakfastList { 62 | print(item.description) 63 | } 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /014-Inits/014.4-FoodSample.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.4-FoodSample.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.4-FoodSample.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.4-FoodSample.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.4-FoodSample.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 014.4-FoodSample (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /014-Inits/014.5-FailableInits.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.5-FailableInits.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.5-FailableInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.5-FailableInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.6-RequiredInits.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.6-RequiredInits.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.6-RequiredInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.6-RequiredInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.6-RequiredInits.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 014.6-RequiredInits (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /014-Inits/014.7-Deinit.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /014-Inits/014.7-Deinit.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /014-Inits/014.7-Deinit.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/014-Inits/014.7-Deinit.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /014-Inits/014.7-Deinit.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 014.7-Deinit (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /015-Optionals/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/015-Optionals/.DS_Store -------------------------------------------------------------------------------- /015-Optionals/015.1-OptionalChaining.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class Person { 2 | var residence: Residence? 3 | } 4 | 5 | class Residence { 6 | var numberOfRooms = 1 7 | } 8 | 9 | 10 | let juangabriel = Person() 11 | print(juangabriel.residence) 12 | //No se puede consultar el valor de una variable opcional 13 | //haciendo unwrapping si no estamos seguros de que ha sido configurada 14 | //print(juangabriel.residence!.numberOfRooms) 15 | 16 | juangabriel.residence = Residence() 17 | 18 | if let roomCount = juangabriel.residence?.numberOfRooms { 19 | //roomCount es de tipo Int? 20 | print("La casa de Juan Gabriel tiene \(roomCount) habitacion(es).") 21 | } else { 22 | print("No tenemos ni idea de las habitaciones de la casa de JB") 23 | } 24 | -------------------------------------------------------------------------------- /015-Optionals/015.1-OptionalChaining.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /015-Optionals/015.1-OptionalChaining.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /015-Optionals/015.1-OptionalChaining.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/015-Optionals/015.1-OptionalChaining.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /015-Optionals/015.1-OptionalChaining.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 015.1-OptionalChaining (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /015-Optionals/015.2-MultilayerOptional.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /015-Optionals/015.2-MultilayerOptional.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /015-Optionals/015.2-MultilayerOptional.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/015-Optionals/015.2-MultilayerOptional.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /015-Optionals/015.2-MultilayerOptional.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 015.2-MultilayerOptional (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /016-Errors/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/016-Errors/.DS_Store -------------------------------------------------------------------------------- /016-Errors/016.1-ErrorHandling.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /016-Errors/016.1-ErrorHandling.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /016-Errors/016.1-ErrorHandling.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/016-Errors/016.1-ErrorHandling.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /017-Castings/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/017-Castings/.DS_Store -------------------------------------------------------------------------------- /017-Castings/017-1-Castings.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /017-Castings/017-1-Castings.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /017-Castings/017-1-Castings.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/017-Castings/017-1-Castings.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /017-Castings/017-1-Castings.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 17-1-Castings (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /017-Castings/017-2-AnyObjects.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /017-Castings/017-2-AnyObjects.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /017-Castings/017-2-AnyObjects.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/017-Castings/017-2-AnyObjects.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /017-Castings/017-2-AnyObjects.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 17-2-AnyObjects (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /018-NestedTypes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/018-NestedTypes/.DS_Store -------------------------------------------------------------------------------- /018-NestedTypes/018-Blackjack.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /018-NestedTypes/018-Blackjack.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /018-NestedTypes/018-Blackjack.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/018-NestedTypes/018-Blackjack.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /018-NestedTypes/018-Blackjack.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 018-Blackjack (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /019-Extensions/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/019-Extensions/.DS_Store -------------------------------------------------------------------------------- /019-Extensions/019-01-Extensions.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | /*struct SomeStructure{ 2 | let x:Int 3 | 4 | } 5 | 6 | extension SomeStructure { 7 | //Incorporar aquí funcionalidades a SomeStructure que no tuviera originalmente... 8 | } 9 | 10 | extension SomeStructure: SomeProtocol, AnotherProtocol { 11 | 12 | }*/ 13 | 14 | extension Double{ 15 | 16 | var km:Double { return self * 1_000.0} 17 | var m:Double { return self } 18 | var cm: Double { return self / 100.0} 19 | var mm : Double { return self / 1_000.0} 20 | 21 | var ft : Double { return self / 3.28084} 22 | 23 | } 24 | 25 | let halfKm = 0.5.km 26 | let threeFeet = 3.ft 27 | let oneInch = 25.4.mm 28 | 29 | print("\(halfKm) m ") 30 | 31 | let marathon = 42.km + 195.m 32 | 33 | print("Una maratón son \(marathon) m") 34 | -------------------------------------------------------------------------------- /019-Extensions/019-01-Extensions.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /019-Extensions/019-01-Extensions.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /019-Extensions/019-01-Extensions.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/019-Extensions/019-01-Extensions.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /019-Extensions/019-01-Extensions.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 019-01-Extensions (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /019-Extensions/019-02-ExtensionInits.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | struct Size { 2 | var width = 0.0, height = 0.0 3 | } 4 | struct Point { 5 | var x = 0.0, y = 0.0 6 | } 7 | struct Rect { 8 | var origin = Point() 9 | var size = Size() 10 | } 11 | 12 | 13 | 14 | let defaultRect = Rect() 15 | let randomRect = Rect(origin: Point(x:2.0, y:-5.0), size: Size(width: 10.0, height: 12.0)) 16 | 17 | 18 | 19 | extension Rect { 20 | init(center: Point, size: Size) { 21 | let originX = center.x - size.width / 2.0 22 | let originY = center.y - size.height / 2.0 23 | self.init(origin: Point(x: originX, y: originY), size: size) 24 | } 25 | } 26 | 27 | let centeredRect = Rect(center: Point(), size: Size(width: 2.0, height: 2.0)) 28 | let anotherCeteredRect = Rect(center: Point(x: 3.0, y: 5.0), size: Size(width: 4.0, height: 3.0)) 29 | -------------------------------------------------------------------------------- /019-Extensions/019-02-ExtensionInits.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /019-Extensions/019-02-ExtensionInits.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /019-Extensions/019-02-ExtensionInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/019-Extensions/019-02-ExtensionInits.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /019-Extensions/019-02-ExtensionInits.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 019-02-ExtensionInits (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /019-Extensions/019-03-ExtensionMethods.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | extension Int { 2 | func repetitions(task: () -> Void) { 3 | for _ in 0.. 2 | 3 | 4 | -------------------------------------------------------------------------------- /019-Extensions/019-03-ExtensionMethods.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /019-Extensions/019-03-ExtensionMethods.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 019-03-ExtensionMethods (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /019-Extensions/019-04-ExtensionSubscripts.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //123456789[0] = 9 2 | //123456789[1] = 8 3 | //123456789[2] = 7 4 | 5 | extension Int { 6 | subscript(digitIndex: Int) -> Int { 7 | var decimalBase = 1 8 | for _ in 0.. 2 | 3 | 4 | -------------------------------------------------------------------------------- /019-Extensions/019-04-ExtensionSubscripts.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /019-Extensions/019-04-ExtensionSubscripts.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 019-04-ExtensionSubscripts (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /019-Extensions/019-05-ExtensionNested.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | extension Int { 2 | enum Kind { 3 | case negative, zero, positive 4 | } 5 | 6 | var kind: Kind { 7 | switch self { 8 | case 0: 9 | return .zero 10 | case let x where x > 0: 11 | return .positive 12 | default: 13 | return .negative 14 | } 15 | } 16 | } 17 | 18 | 19 | func printIntegerKinds(_ numbers : [Int]){ 20 | for number in numbers { 21 | switch number.kind { 22 | case .negative: 23 | print("- ", terminator: "") 24 | case .zero: 25 | print("0 ", terminator: "") 26 | case .positive: 27 | print("+ ", terminator: "") 28 | } 29 | } 30 | print("") 31 | } 32 | 33 | 34 | printIntegerKinds([3,17,-8,0,-5,0,17,-23,32]) 35 | 36 | 37 | 38 | Int.Kind.positive 39 | -------------------------------------------------------------------------------- /019-Extensions/019-05-ExtensionNested.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /019-Extensions/019-05-ExtensionNested.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /019-Extensions/019-05-ExtensionNested.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 019-05-ExtensionNested (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/.DS_Store -------------------------------------------------------------------------------- /020-Protocols/020-01-Protocols.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol SomeProtocol { 2 | //aquí iría la definición del protocolo... 3 | } 4 | 5 | protocol AnotherProtocol { 6 | 7 | } 8 | 9 | struct SomeStruct : SomeProtocol, AnotherProtocol { 10 | 11 | } 12 | 13 | enum SomeEnum : SomeProtocol { 14 | 15 | } 16 | 17 | 18 | class SuperClass{ 19 | //Aquí va la declaración de la super clase 20 | } 21 | 22 | class SubClass : SuperClass, SomeProtocol, AnotherProtocol { 23 | //Aquí va la declaración de la subclase 24 | } 25 | 26 | class SomeClass : SomeProtocol { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /020-Protocols/020-01-Protocols.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-01-Protocols.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-01-Protocols.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-01-Protocols.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-01-Protocols.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-01-Protocols (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-02-ProtocolProperties.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol SomeProtocol{ 2 | var mustBeSettable : Int { get set } 3 | var doesntNeedToBeSettable : Int { get } 4 | static var someTypeProperty : Int { get set } 5 | } 6 | 7 | protocol FullyNamed { 8 | var fullName : String { get } 9 | } 10 | 11 | struct Person : FullyNamed { 12 | var fullName:String 13 | } 14 | 15 | let jb = Person(fullName: "Juan Gabriel") 16 | 17 | 18 | class Starship : FullyNamed { 19 | var prefix : String? 20 | var name: String 21 | 22 | init(name: String, prefix: String? = nil) { 23 | self.name = name 24 | self.prefix = prefix 25 | } 26 | 27 | var fullName: String { 28 | return (prefix != nil ? prefix!+" " : "") + name 29 | } 30 | 31 | } 32 | 33 | var firstSpaceship = Starship(name: "Enterprise", prefix: "USS") 34 | firstSpaceship.fullName 35 | 36 | var secondSpaceship = Starship(name: "Halcón Milenario") 37 | secondSpaceship.fullName 38 | -------------------------------------------------------------------------------- /020-Protocols/020-02-ProtocolProperties.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-02-ProtocolProperties.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-02-ProtocolProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-02-ProtocolProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-02-ProtocolProperties.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-02-ProtocolProperties (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-03-ProtocolMethods.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol SomeProtocol { 2 | func someFunc() 3 | static func someTypeMethod() 4 | } 5 | 6 | 7 | protocol RandomNumberGenerator { 8 | func random() -> Double 9 | } 10 | 11 | 12 | class LinearCongruentialGenerator : RandomNumberGenerator { 13 | var lastRandom = 29.0 14 | let m = 139968.0 15 | let a = 3877.0 16 | let c = 29573.0 17 | 18 | func random() -> Double { 19 | lastRandom = (lastRandom * a + c).truncatingRemainder(dividingBy: m) 20 | return lastRandom / m 21 | } 22 | 23 | } 24 | 25 | let generator = LinearCongruentialGenerator() 26 | 27 | for _ in 1...10 { 28 | print(generator.random()) 29 | } 30 | 31 | 32 | 33 | protocol Togglable { 34 | mutating func toggle() 35 | } 36 | 37 | enum OnOffSwitch : Togglable { 38 | case on, off 39 | 40 | mutating func toggle() { 41 | switch self { 42 | case .on: 43 | self = .off 44 | case .off: 45 | self = .on 46 | } 47 | } 48 | } 49 | 50 | 51 | var bedroomLight = OnOffSwitch.on 52 | bedroomLight.toggle() 53 | bedroomLight.toggle() 54 | 55 | -------------------------------------------------------------------------------- /020-Protocols/020-03-ProtocolMethods.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-03-ProtocolMethods.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-03-ProtocolMethods.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-03-ProtocolMethods.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-03-ProtocolMethods.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-03-ProtocolMethods (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-04-ProtocolInits.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol SomeProtocol{ 2 | init(someParameter: Int) 3 | } 4 | 5 | class SomeClass : SomeProtocol { 6 | required init(someParameter: Int) { 7 | //cuerpo del inicializador... 8 | } 9 | } 10 | 11 | protocol SingleProtocol { 12 | init() 13 | } 14 | 15 | class SingleSuperClass{ 16 | init(){ 17 | //aquí va la implementación del init de la superclase 18 | } 19 | } 20 | 21 | class SingleSubclass: SingleSuperClass, SingleProtocol { 22 | //required: por ser un init conformado de un protocolo y la clase no ser final 23 | //override: por ser una subclase de una clase madre con dicho init 24 | required override init(){ 25 | //aquí va la implementación del init de la subclase 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /020-Protocols/020-04-ProtocolInits.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-04-ProtocolInits.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-04-ProtocolInits.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-04-ProtocolInits.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-04-ProtocolInits.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-04-ProtocolInits (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-05-ProtocolTypes.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-05-ProtocolTypes.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-05-ProtocolTypes.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-05-ProtocolTypes.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-05-ProtocolTypes.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-05-ProtocolTypes (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-06-ProtocolComparison.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol Named { 2 | var name: String { get } 3 | } 4 | 5 | protocol Aged { 6 | var age: Int { get } 7 | } 8 | 9 | struct Person : Named, Aged { 10 | var name:String 11 | var age: Int 12 | } 13 | 14 | func wishHappyBirthay(to celebrator: Named & Aged){ 15 | print("Feliz cumpleaños \(celebrator.name), ahora tienes \(celebrator.age) años!") 16 | } 17 | 18 | wishHappyBirthay(to: Person(name: "Juan Gabriel", age: 29)) 19 | 20 | 21 | 22 | 23 | 24 | class Location { 25 | var latitude: Double 26 | var longitude: Double 27 | 28 | init(latitude: Double, longitude: Double) { 29 | self.latitude = latitude 30 | self.longitude = longitude 31 | } 32 | } 33 | 34 | 35 | class City : Location, Named { 36 | var name: String 37 | init(name: String, latitude: Double, longitude: Double) { 38 | self.name = name 39 | super.init(latitude: latitude, longitude: longitude) 40 | } 41 | } 42 | 43 | 44 | func beginTravel(to location: Location & Named){ 45 | print("Bienvenido a \(location.name)!!!") 46 | } 47 | 48 | let seattle = City(name: "Seattle", latitude: 47.6, longitude: -122.3) 49 | beginTravel(to: seattle) 50 | 51 | 52 | //Da error de commpilación 53 | //beginTravel(to: Person(name: "JB", age: 29)) 54 | -------------------------------------------------------------------------------- /020-Protocols/020-06-ProtocolComparison.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-06-ProtocolComparison.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-06-ProtocolComparison.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-06-ProtocolComparison.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-06-ProtocolComparison.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-06-ProtocolComparison (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-07-ProtocolConformance.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol HasArea{ 2 | var area: Double { get } 3 | } 4 | 5 | class Circle: HasArea { 6 | let pi = 3.15159265 7 | var radius: Double 8 | var area: Double { 9 | return pi * radius * radius 10 | } 11 | init(radius : Double) { 12 | self.radius = radius 13 | } 14 | } 15 | 16 | 17 | class Country : HasArea{ 18 | var area : Double 19 | init(area:Double) { 20 | self.area = area 21 | } 22 | } 23 | 24 | class Animal { 25 | var legs : Int 26 | init(legs: Int) { 27 | self.legs = legs 28 | } 29 | } 30 | 31 | let objects:[AnyObject] = [ 32 | Circle(radius: 3.0), 33 | Country(area: 123_456), 34 | Animal(legs: 4) 35 | ] 36 | 37 | 38 | for object in objects { 39 | if let objectWithArea = object as? HasArea { 40 | print("El area es \(objectWithArea.area)") 41 | }else { 42 | print("Este objeto no tiene área conocida...") 43 | } 44 | } 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /020-Protocols/020-07-ProtocolConformance.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-07-ProtocolConformance.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-07-ProtocolConformance.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-07-ProtocolConformance.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-08-OptionalProtocols.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //someMethod(Int) -> String 2 | //((Int) -> String)? 3 | //someMethod?(someArgument) 4 | import Foundation 5 | 6 | @objc protocol CounterDataSource { 7 | @objc optional func increment(forCount count: Int) -> Int 8 | @objc optional var fixedIncrement : Int { get } 9 | } 10 | 11 | class Counter { 12 | var count = 0 13 | var dataSource: CounterDataSource? 14 | 15 | func increment() { 16 | if let amount = dataSource?.increment?(forCount: count){ 17 | count += amount 18 | } else if let amount = dataSource?.fixedIncrement { 19 | count += amount 20 | } 21 | } 22 | } 23 | 24 | class FiveSource : NSObject, CounterDataSource { 25 | let fixedIncrement: Int = 5 26 | } 27 | 28 | var counter = Counter() 29 | counter.dataSource = FiveSource() 30 | 31 | for _ in 1...10 { 32 | counter.increment() 33 | print(counter.count) 34 | } 35 | 36 | 37 | class TowardsZeroSource : NSObject, CounterDataSource{ 38 | func increment(forCount count: Int) -> Int { 39 | if count == 0 { 40 | return 0 41 | } else if count < 0 { 42 | return 1 43 | } else { 44 | return -1 45 | } 46 | } 47 | } 48 | 49 | 50 | counter.dataSource = TowardsZeroSource() 51 | counter.count = -8 52 | 53 | while counter.count != 0 { 54 | counter.increment() 55 | print(counter.count) 56 | } 57 | 58 | -------------------------------------------------------------------------------- /020-Protocols/020-08-OptionalProtocols.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-08-OptionalProtocols.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-08-OptionalProtocols.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-08-OptionalProtocols (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /020-Protocols/020-09-ProtocolExtension.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /020-Protocols/020-09-ProtocolExtension.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /020-Protocols/020-09-ProtocolExtension.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/020-Protocols/020-09-ProtocolExtension.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /020-Protocols/020-09-ProtocolExtension.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 020-09-ProtocolExtension (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /021-Generics/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/021-Generics/.DS_Store -------------------------------------------------------------------------------- /021-Generics/021-01-Generics.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | /*func swapTwoInts(_ a: inout Int, _ b: inout Int){ 2 | let temp = a 3 | a = b 4 | b = temp 5 | } 6 | 7 | var someInt = 5 8 | var anotherInt = 29 9 | swapTwoInts(&someInt, &anotherInt) 10 | print("Some Int ahora vale \(someInt) mientras que Another Int ahora vale \(anotherInt)") 11 | 12 | func swapTwoString(_ a: inout String, _ b: inout String){ 13 | let temp = a 14 | a = b 15 | b = temp 16 | } 17 | 18 | func swapTwoDoubles(_ a: inout Double, _ b: inout Double){ 19 | let temp = a 20 | a = b 21 | b = temp 22 | } 23 | */ 24 | func swapTwoValues(_ a: inout T, _ b: inout T){ 25 | let temp = a 26 | a = b 27 | b = temp 28 | } 29 | 30 | var someInt = 5 31 | var anotherInt = 29 32 | swapTwoValues(&someInt, &anotherInt) 33 | print("Some Int ahora vale \(someInt) mientras que Another Int ahora vale \(anotherInt)") 34 | 35 | 36 | var someString = "Juan" 37 | var anotherString = "Gabriel" 38 | swapTwoValues(&someString, &anotherString) 39 | print("\(someString) \(anotherString) ") 40 | 41 | 42 | //Array 43 | //Dictionary 44 | -------------------------------------------------------------------------------- /021-Generics/021-01-Generics.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /021-Generics/021-01-Generics.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /021-Generics/021-01-Generics.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/021-Generics/021-01-Generics.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /021-Generics/021-01-Generics.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 021-01-Generics (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /021-Generics/021-02-GenericsTypes.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | struct IntStack { 2 | var items = [Int]() 3 | 4 | mutating func push(_ item: Int){ 5 | items.append(item) 6 | } 7 | 8 | mutating func pop() -> Int { 9 | return items.removeLast() 10 | } 11 | } 12 | 13 | struct Stack { 14 | var items = [Element]() 15 | 16 | mutating func push(_ item: Element){ 17 | items.append(item) 18 | } 19 | 20 | mutating func pop() -> Element{ 21 | return items.removeLast() 22 | } 23 | } 24 | 25 | 26 | extension Stack { 27 | var topItem : Element? { 28 | if items.isEmpty { 29 | return nil 30 | }else { 31 | return items[items.count-1] 32 | } 33 | } 34 | } 35 | 36 | 37 | var stackOfString = Stack() 38 | stackOfString.push("uno") 39 | stackOfString.push("dos") 40 | stackOfString.push("tres") 41 | stackOfString.push("cuatro") 42 | 43 | 44 | let lastElement = stackOfString.pop() 45 | 46 | if let topItem = stackOfString.topItem { 47 | print("El último ítem de la pila es \(topItem)") 48 | } 49 | -------------------------------------------------------------------------------- /021-Generics/021-02-GenericsTypes.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /021-Generics/021-02-GenericsTypes.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /021-Generics/021-02-GenericsTypes.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/021-Generics/021-02-GenericsTypes.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /021-Generics/021-02-GenericsTypes.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 021-02-GenericsTypes (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /021-Generics/021-03-GenericsConstraints.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class SomeClass{ 2 | 3 | } 4 | protocol SomeProtocol { 5 | 6 | } 7 | 8 | func someGenericFunctionWithConstraints(someT: T, someU: U){ 9 | 10 | } 11 | 12 | func findIndex(ofString valueToFind : String, in array:[String]) -> Int? { 13 | for (index, value) in array.enumerated() { 14 | if value == valueToFind { 15 | return index 16 | } 17 | } 18 | return nil 19 | } 20 | 21 | let strings = ["perro", "gato", "araña", "buho", "león", "conejo"] 22 | 23 | if let foundIndex = findIndex(ofString: "buho", in: strings){ 24 | print("La posición del buho es la \(foundIndex)") 25 | } 26 | 27 | 28 | func findIndex(of valueToFind: T, in array : [T]) -> Int? { 29 | for (index, value) in array.enumerated() { 30 | if value == valueToFind { 31 | return index 32 | } 33 | } 34 | return nil 35 | } 36 | 37 | 38 | let doubleIndex = findIndex(of: 4.5, in: [3.141592, 0.125,0.32, 5.3]) 39 | 40 | let stringIndex = findIndex(of: "león", in: strings) 41 | -------------------------------------------------------------------------------- /021-Generics/021-03-GenericsConstraints.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /021-Generics/021-03-GenericsConstraints.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /021-Generics/021-03-GenericsConstraints.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 021-03-GenericsConstraints (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /021-Generics/021-04-AssociatedTypes.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /021-Generics/021-04-AssociatedTypes.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /021-Generics/021-04-AssociatedTypes.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 021-04-AssociatedTypes (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /021-Generics/021-05-AssociatedTypes2.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | protocol Container { 2 | associatedtype Item 3 | mutating func append(_ item : Item) 4 | var count : Int { get } 5 | subscript(i: Int) -> Item { get } 6 | 7 | associatedtype Iterator : IteratorProtocol where Iterator.Element == Item 8 | func makeIterator() -> Iterator 9 | } 10 | 11 | protocol ComparableContainer : Container where Item: Comparable { 12 | 13 | } 14 | 15 | 16 | extension Container{ 17 | subscript(indices : Indices) -> [Item] 18 | where Indices.Iterator.Element == Int { 19 | var result = [Item]() 20 | for index in indices { 21 | result.append(self[index]) 22 | } 23 | return result 24 | } 25 | } 26 | 27 | //objects[2...5] 28 | -------------------------------------------------------------------------------- /021-Generics/021-05-AssociatedTypes2.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /021-Generics/021-05-AssociatedTypes2.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /021-Generics/021-05-AssociatedTypes2.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 021-05-AssociatedTypes2 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /022-ARC/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/022-ARC/.DS_Store -------------------------------------------------------------------------------- /022-ARC/022-01-ARC.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //ARC 2 | class Person { 3 | let name: String 4 | init(name: String) { 5 | self.name = name 6 | print("\(name) esta siendo inicializado") 7 | } 8 | deinit { 9 | print("\(name) está siendo desinicializado") 10 | } 11 | } 12 | 13 | var person1: Person? 14 | var person2: Person? 15 | var person3: Person? 16 | 17 | person1 = Person(name: "Juan Gabriel") 18 | person2 = person1 19 | person3 = person1 20 | 21 | person1 = nil 22 | person2 = nil 23 | 24 | person3 = nil 25 | -------------------------------------------------------------------------------- /022-ARC/022-01-ARC.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /022-ARC/022-01-ARC.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /022-ARC/022-01-ARC.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 022-01-ARC (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /022-ARC/022-02-ARC-Cycles.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class Person{ 2 | let name : String 3 | var apartment : Apartment? 4 | init(name: String) { 5 | self.name = name 6 | } 7 | 8 | deinit { 9 | print("\(name) ha sido desinicializado") 10 | } 11 | 12 | } 13 | 14 | class Apartment { 15 | let unit : String 16 | weak var tenant: Person? 17 | init(unit : String) { 18 | self.unit = unit 19 | } 20 | 21 | deinit { 22 | print("El apartamento \(unit) ha sido desinicializado") 23 | } 24 | } 25 | 26 | var jb : Person? 27 | var apartment : Apartment? 28 | 29 | jb = Person(name: "Juan Gabriel") 30 | apartment = Apartment(unit: "4A") 31 | 32 | jb!.apartment = apartment 33 | apartment!.tenant = jb 34 | 35 | jb = nil 36 | apartment = nil 37 | -------------------------------------------------------------------------------- /022-ARC/022-02-ARC-Cycles.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /022-ARC/022-02-ARC-Cycles.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /022-ARC/022-02-ARC-Cycles.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 022-02-ARC-Cycles (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /022-ARC/022-03-ARC-Unowned.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class Customer { 2 | let name: String 3 | var card : CreditCard? 4 | init(name: String) { 5 | self.name = name 6 | } 7 | deinit { 8 | print("\(name) está siendo desinicializado") 9 | } 10 | } 11 | 12 | class CreditCard { 13 | let number : UInt64 14 | unowned let customer : Customer 15 | init(number: UInt64, customer: Customer) { 16 | self.number = number 17 | self.customer = customer 18 | } 19 | deinit { 20 | print("La tarjeta de crédito #\(number) está siendo desinicializada") 21 | } 22 | } 23 | 24 | var jb : Customer? 25 | jb = Customer(name: "Juan Gabriel") 26 | 27 | jb!.card = CreditCard(number: 1234_5678_9012_3456, customer: jb!) 28 | 29 | jb = nil 30 | -------------------------------------------------------------------------------- /022-ARC/022-03-ARC-Unowned.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /022-ARC/022-03-ARC-Unowned.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /022-ARC/022-03-ARC-Unowned.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 022-03-ARC-Unowned (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /022-ARC/022-04-ARC-UnownedRefs2.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | class Country { 2 | let name : String 3 | var capitalCity : City! 4 | init(name: String, capitalName: String) { 5 | self.name = name 6 | self.capitalCity = City(name: capitalName, country: self) 7 | } 8 | } 9 | 10 | class City { 11 | let name : String 12 | unowned let country : Country 13 | init(name: String, country: Country) { 14 | self.name = name 15 | self.country = country 16 | } 17 | } 18 | 19 | var country = Country(name: "España", capitalName: "Madrid") 20 | print("La capital de \(country.name) es \(country.capitalCity.name)") 21 | -------------------------------------------------------------------------------- /022-ARC/022-04-ARC-UnownedRefs2.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /022-ARC/022-04-ARC-UnownedRefs2.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /022-ARC/022-04-ARC-UnownedRefs2.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/022-ARC/022-04-ARC-UnownedRefs2.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /022-ARC/022-04-ARC-UnownedRefs2.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 022-04-ARC-UnownedRefs2 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /022-ARC/022-05-ARC-Closures.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /022-ARC/022-05-ARC-Closures.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /022-ARC/022-05-ARC-Closures.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/022-ARC/022-05-ARC-Closures.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /022-ARC/022-05-ARC-Closures.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 022-05-ARC-Closures (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /023-MemoryManagement/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/023-MemoryManagement/.DS_Store -------------------------------------------------------------------------------- /023-MemoryManagement/023-01-MemoryAccess.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //Esto es una operación de escritura en memoria 2 | var five = 5 3 | //Esta operación es de lectura desde la memoria 4 | print("Tenemos el número \(five)") 5 | 6 | //Al menos uno es de escritura 7 | //Ambos tienen acceso a la misma posición de memoria 8 | //La duración de ambos se superpone 9 | 10 | 11 | func addOne(number: Int ) -> Int { 12 | return number + 1 13 | } 14 | 15 | var myNumber = 1 16 | myNumber = addOne(number: myNumber) 17 | print(myNumber) 18 | 19 | 20 | 21 | 22 | var stepSize = 1 23 | func increment(_ number: inout Int) { 24 | number += stepSize 25 | } 26 | 27 | var copyOfStepSize = stepSize //aquí la copia vale 1 28 | increment(©OfStepSize) //lectura y ecritura en diferentes posiciones de memoria 29 | stepSize = copyOfStepSize 30 | 31 | 32 | func balance (_ x: inout Int, _ y : inout Int) { 33 | let sum = x+y 34 | x = sum / 2 35 | y = sum - x 36 | } 37 | 38 | 39 | var scoreOne = 42 40 | var scoreTwo = 30 41 | balance(&scoreOne, &scoreTwo) //OK 42 | //balance(&scoreOne, &scoreOne) 43 | var copyOfScoreOne = scoreOne 44 | balance(&scoreOne, ©OfScoreOne) 45 | 46 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-01-MemoryAccess.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-01-MemoryAccess.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-01-MemoryAccess.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/023-MemoryManagement/023-01-MemoryAccess.playground/playground.xcworkspace/xcuserdata/JuanGabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /023-MemoryManagement/023-01-MemoryAccess.playground/timeline.xctimeline: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-01-MemoryAccess.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 023-01-MemoryAccess (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-02-MemoryAccessProperties.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-02-MemoryAccessProperties.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /023-MemoryManagement/023-02-MemoryAccessProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/023-MemoryManagement/023-02-MemoryAccessProperties.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /023-MemoryManagement/023-02-MemoryAccessProperties.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 023-02-MemoryAccessProperties (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /024-AccessControl/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/024-AccessControl/.DS_Store -------------------------------------------------------------------------------- /024-AccessControl/024-01-AccessControl.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | /* 2 | open 3 | public 4 | internal 5 | fileprivate 6 | private 7 | */ 8 | 9 | 10 | open class SomeOpenClass{} 11 | public class SomePublicClass{} 12 | internal class SomeInternalClass{} 13 | fileprivate class SomeFilePrivateClass{} 14 | private class SomePrivateClass{} 15 | 16 | public var somePublicVariable = 0 17 | internal let someInternalConstant = 0 18 | fileprivate func someFilePrivateFunction(){} 19 | private func somePrivateFunc(){} 20 | 21 | class SomeRandomClass{} //Por defecto, es implícitamente internal 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /024-AccessControl/024-01-AccessControl.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /024-AccessControl/024-01-AccessControl.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /024-AccessControl/024-01-AccessControl.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 024-01-AccessControl (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /024-AccessControl/024-02-AccessControl2.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /024-AccessControl/024-02-AccessControl2.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /024-AccessControl/024-02-AccessControl2.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/024-AccessControl/024-02-AccessControl2.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /024-AccessControl/024-02-AccessControl2.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 024-02-AccessControl2 (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /025-AdvancedOperators/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/025-AdvancedOperators/.DS_Store -------------------------------------------------------------------------------- /025-AdvancedOperators/025-01-BitwiseOperators.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //Operador unario prefijo NOT 2 | //UInt8 es un entero de 8 bits que puede guardar números desde 0 hasta 255 3 | let initialBits: UInt8 = 0b00001111 4 | let invertedBits = ~initialBits //el resultado es 11110000 5 | 6 | 7 | //Operador binario infijo AND 8 | let firstSixBits: UInt8 = 0b11111100 9 | let lastSixBits : UInt8 = 0b00111111 10 | let middleFourBits = firstSixBits & lastSixBits // 00111100 11 | 12 | //Operador binario infijo OR 13 | let someBits : UInt8 = 0b10110010 14 | let moreBits : UInt8 = 0b01011110 15 | let combinedBits = someBits | moreBits //11111110 16 | 17 | //Operador binario infijo XOR 18 | let firstBits: UInt8 = 0b00010100 19 | let otherBits: UInt8 = 0b00000101 20 | let outputBits : UInt8 = firstBits ^ otherBits // 00010001 21 | 22 | //Operador unario postfijo intercambio lógico 23 | let allOnes : UInt8 = 0b11111111 24 | let oneToTheLeft = allOnes << 1 25 | let oneToTheRight = allOnes >> 1 26 | 27 | let shiftBits : UInt8 = 4 //00000100 28 | shiftBits << 1 //00001000 29 | shiftBits << 2 //00010000 30 | shiftBits << 5 //10000000 31 | shiftBits << 6 //00000000 32 | shiftBits >> 2 //00000001 33 | 34 | let pink : UInt32 = 0xCC6699 35 | 36 | let red : UInt32 = 0xFF0000 37 | let green : UInt32 = 0x00FF00 38 | let blue : UInt32 = 0x0000FF 39 | 40 | let redComponent = (pink & red) >> 16 //0x0000CC 41 | let greenComponent = (pink & green) >> 8 //0x0066 42 | let blueComponent = (pink & blue) //0x000099 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-01-BitwiseOperators.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-01-BitwiseOperators.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-01-BitwiseOperators.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/025-AdvancedOperators/025-01-BitwiseOperators.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /025-AdvancedOperators/025-01-BitwiseOperators.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 025-01-BitwiseOperators (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-02-Overflow.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | 2 | //Int16 [-32768, 32767] 3 | var potentialOverflow = Int16.max 4 | //potentialOverflow += 1 5 | 6 | potentialOverflow = potentialOverflow &+ 1 7 | 8 | var unsignedOverflow = UInt8.max //11111111 9 | unsignedOverflow = unsignedOverflow &+ 1 10 | 11 | var anotherUnsignedOverflow = UInt8.min 12 | anotherUnsignedOverflow = anotherUnsignedOverflow &- 1 13 | 14 | 15 | var signedOverflow = Int8.min 16 | signedOverflow = signedOverflow &- 1 17 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-02-Overflow.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-02-Overflow.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-02-Overflow.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 025-02-Overflow (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-03-Precedence-Associativity.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | 2 + ((3 % 4) * 5) 2 | 2 + (3 * 5) 3 | 2 + 15 4 | 17 5 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-03-Precedence-Associativity.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-03-Precedence-Associativity.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-03-Precedence-Associativity.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/025-AdvancedOperators/025-03-Precedence-Associativity.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /025-AdvancedOperators/025-03-Precedence-Associativity.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 025-03-Precedence-Associativity (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-04-Method-Operators.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-04-Method-Operators.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /025-AdvancedOperators/025-04-Method-Operators.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joanby/curso-de-swift/fc6604c51196421b7474ca0f92806ad189b0a46b/025-AdvancedOperators/025-04-Method-Operators.playground/playground.xcworkspace/xcuserdata/juangabriel.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /025-AdvancedOperators/025-04-Method-Operators.playground/xcuserdata/juangabriel.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 025-04-Method-Operators (Playground).xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------