Created
December 3, 2015 21:10
-
-
Save fitomad/7d833536b2de0d52a2e4 to your computer and use it in GitHub Desktop.
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
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") | |
if let movie = movie | |
{ | |
print("Tenemos datos para la pelicula: \(movie.name)") | |
if let posters = movie.posters where !posters.isEmpty | |
{ | |
print("Tiene \(posters.count) posters") | |
} | |
if let clearart = movie.clearartsHD where !clearart.isEmpty | |
{ | |
print("Tiene \(clearart.count) HD Clearart") | |
} | |
if let banners = movie.banners where !banners.isEmpty | |
{ | |
print("Tiene \(banners.count) banners") | |
} | |
} | |
else | |
{ | |
print("Esa peli no existe") | |
} | |
// La operacion asincrona ha terminado | |
// Podemos continuar | |
dispatch_semaphore_signal(semaphore) | |
} | |
// Esperamos a que la llamada al servicio termine... | |
// Y aquí esperamos indefinidamente | |
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment