Skip to content

Instantly share code, notes, and snippets.


fitomad/xctest_rest-gcd.swift Secret

Created Feb 13, 2019
What would you like to do?
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: \(")
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")
print("Esa peli no existe")
// La operacion asincrona ha terminado
// Podemos continuar
// 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