dispatch_syncを使う
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// メインスレッドで非同期実行
NSLog(@"1.%@", [NSThread isMainThread]? @"mainThread": @"backgroundThread");
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// 第一引数でキューを指定して同期実行
NSLog(@"2.%@", [NSThread isMainThread]? @"mainThread": @"backgroundThread");
});
return YES;
}
結果