ios - Keep track of all running blocks -


i have list of objects. each of objects contains optional image value, needs dowloaded. want return list after images has been initialised(if any). have nsoperationqueues?

func getfulllist(list:[anyobject], completion:(result: [anyobject]) -> void {    item in list {       downloadimage(item.url), completion: {(image) in       item.image = image    )}    // know not work here    completion(result: list) } 

untested code.

func getfulllist(list:[anyobject], completion:(result: [anyobject]) -> void {     let group = dispatch_group_create()     item in list {         dispatch_group_enter(group)        downloadimage(item.url), completion: {(image) in           item.image = image            dispatch_group_leave(group)       }    )}     dispatch_group_notify(group, dispatch_get_global_queue(dispatch_queue_priority_default, 0)) {         completion(result: list)    } } 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -