I have a function A that contains two other functions B & C. Inside function A I need to call function C once function B has completed. I'm thinking I need to use Grand Central Dispatch's dispatch_group_notify for it, but am not too sure how to use it. I'm calling asynchronous methods in both functions B & C. Here are my functions:
func A() { func B() { // Three asynchronous functions } func C() { // More asynchronous functions that handle results from func B() } funcB() funcC() } EDIT: In func B(), I have three async functions that take awhile to finish. When I use the following method, func C() is still being called before the methods within func B() are completely finished. How do I make sure they're completely finished before the second dispatch group is called?
func A() { var group = dispatch_group_create() dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) { () -> Void in // async function 1 // async function 2 // async function 3 } dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), { () -> Void in // async function }) }
func C()that must only be called once the three async functions infunc B()have finished.NSOperationQueue,NSOperation,addDependency(_:), ...