This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cadena: NSString = "Hola, soy de tipo NSString." | |
let localizacion = NSLocale.currentLocale() | |
let selector = #selector(NSString.lowercaseStringWithLocale(_:)) | |
if let resultado = cadena.performSelector(selector, withObject: localizacion) { | |
print(resultado.takeUnretainedValue()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SpriteKit | |
class GameViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// 1 | |
let gameScene = GameScene(size: CGSize(width: 2048, height: 1536)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SpriteKit | |
class GameScene: SKScene { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
protocol NombreCompleto { | |
var nombreCompleto:String { get } | |
} | |
// 2 | |
class Persona: NombreCompleto { | |
// 3 | |
var nombre: String | |
var apellidos: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ejemplo de protocolo con propiedades | |
protocol UnProtocolo { | |
var permiteEstablecerYDevolverUnValor: String { get set } | |
var permiteSoloDevolverUnValor: Int { get } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
protocol Hablar { | |
func decirHola(nombre: String) | |
} | |
// 2 | |
class Persona: Hablar { | |
// 3 | |
func decirHola(nombre: String) { | |
// 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clase que hereda de una super clase e implementa dos protocolos | |
class UnaClase: SuperClase, UnProtocolo, OtroProtocolo { | |
// aquí va la definición | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// estructura que implementa dos protocolos | |
struct UnaEstructura: UnProtocolo, OtroProtocolo { | |
// aquí va la definición | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inicialización usando el valor raw | |
enum Monedas: Int { | |
case DolarAmericano | |
case PesoCubano | |
case LibraEsterlina | |
case Yen | |
} | |
let moneda = Monedas(rawValue: 3) |
NewerOlder