I want to run a for loop
with background code, that has something happen once it's finished iterating through every item. To do this without background code would be simple, like this:
for aString: String in strings {
if string.utf8Length < 4 {
continue
}
//Some background stuff
}
//Something to do upon completion
But to include background code in there means that the code to perform upon completion gets performed before all items are dealt with.
for aString: String in strings {
if string.utf8Length < 4 {
continue
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) {
//Some background stuff
}
}
//Something to do upon completion
I'm wondering if it's possible to do that.