I suspect that you did not create an iOS project (or any other type of project that runs runloop), but a "Command Line Tool". If it is true:
Your first approach
, , main() (, , ), .
: , .
. wait , ( ), , , .
, , :
dispatch_group_t aGroup = dispatch_group_create();
VoidBlock aBlock = ^{
NSLog(@"do work in main queue");
dispatch_group_leave(aGroup);
};
dispatch_group_enter(aGroup);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), aBlock);
dispatch_group_wait(aGroup, DISPATCH_TIME_FOREVER);
, (), () .
@Ishahaks answer, " " " ", ( "iOS",), main(). , iOS runloop (while(true) { // wait for events }), - main(). . Runloop.