This file contains hidden or 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
| // | |
| // In *Swift 2* this works cause `private` means | |
| // **inside this file** | |
| // | |
| // | |
| // MARK: - A Class | |
| // | |
| internal class FilterView: UIView |
This file contains hidden or 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
| // | |
| // Las variables `queue` y `timer` deben estar deblaradas | |
| // como variables de la clase para así no perder la | |
| // referencia. | |
| // | |
| // queue es de `tipo dispatch_queue_t` | |
| // timer es de tipo `dispatch_source_t` | |
| // | |
| private func createTimer() -> Void | |
| { |
This file contains hidden or 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
| /** | |
| Execute closure after a delay | |
| - Parameters: | |
| -delay: Time to wait until execute closure | |
| - closure: What is going to be executed | |
| */ | |
| public func delay(delay: Double, closure: () -> ()) | |
| { | |
| let time_gcd: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC))) |
This file contains hidden or 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
| // | |
| // Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 42591f7cba) | |
| // Target: x86_64-unknown-linux-gnu | |
| // | |
| // [Swift IBM Sandbox](http://swiftlang.ng.bluemix.net/#/repl) | |
| // | |
| import Foundation | |
| /// |
This file contains hidden or 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
| /// | |
| /// La aportación de **Louis Van Gaal** | |
| /// al desarrollo del lenguaje Swift. | |
| /// | |
| /// La explicación en este vídeo de [Youtube](https://www.youtube.com/watch?v=Od5PQoRr7hU) | |
| /// | |
| extension SignedIntegerType | |
| { | |
| /** | |
| Convierte un número entero en negativo |
This file contains hidden or 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
| /// | |
| /// Prueba de rendimiento para la operacion | |
| /// de recuperacion de datos para una serie de TV | |
| /// | |
| func testShow() | |
| { | |
| // Manhattan Love Story | |
| let showID: Int = 281624 | |
| // Closure de rendimiento |
This file contains hidden or 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
| func testMovie() | |
| { | |
| // 214756 - Ted 2 | |
| // Este es el semaforo | |
| let semaphore: dispatch_semaphore_t = dispatch_semaphore_create(0) | |
| FanartClient.sharedInstance.fanartForMovie(214756) { (movie, error) -> (Void) in | |
| // Comprobamos si hay error... | |
| XCTAssertNil(error, "Se ha producido un error en el framework") |
This file contains hidden or 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
| func testMovie() | |
| { | |
| // 214756 - Ted 2 | |
| // Creamos el objeto que nos ayudara a probar | |
| // la operacion asincrona | |
| let expectation: XCTestExpectation = self.expectationWithDescription("Test fanartForMovie()...") | |
| FanartClient.sharedInstance.fanartForMovie(214756) { (movie, error) -> (Void) in | |
| // Comprobamos si hay error... |
This file contains hidden or 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
| // Creacion de un semaforo | |
| let semaphore: dispatch_semaphore_t = dispatch_semaphore_create(0) | |
| // Liberamos el semaforo. | |
| //La ejecuion puede continuar | |
| dispatch_semaphore_signal(semaphore) | |
| // Este es el punto de bloqueo. | |
| // Aqui esperamos a que se llame | |
| // a la funcion `dispatch_semaphore_signal(sem)` | |
| dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER) |
This file contains hidden or 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 fixed_array: [Int] = [ 2, 1, 4, 3, 6, 5, 8, 7, 10, 9] | |
| var mutable_array: [Int] = [ 2, 8, 10, 3, 6, 5, 4, 7, 1, 9] | |
| let new_fixed_array = fixed_array.sort() | |
| mutable_array.sortInPlace() | |
| print("> mutable: \(mutable_array.descriptionWithSeparator(", "))") | |
| print("> fixed: \(fixed_array.descriptionWithSeparator(", "))") | |
| print("> new fixed: \(new_fixed_array.descriptionWithSeparator(", "))") |