You will need to block the main thread of the command line tool until the async work you’re started via
dispatch_async
is complete. The best approach depends on your specific situation. For example:
You could just a dispatch group (
dispatch_group_create
), enter the group when you start work (dispatch_group_enter
), leave the group when the work is done (dispatch_group_leave
), and have the main thread wait for the group to be done (dispatch_group_wait
).You could ‘park’ the main thread in
dispatch_main
and then have the work, when it’s done, explicitly exit the tool by calling exit
.You could combine these techniques by using a notifying dispatch group (
dispatch_group_notify
).
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
WWDC runs Mon, 13 Jun through to Fri, 17 Jun. During that time all of DTS will be at the conference, helping folks out face-to-face. http://developer.apple.com/wwdc/