5
クエリは、こののように、バックグラウンドのキューを提供することにより、バックグラウンドスレッドでコールバックすることができます例:
service.delegateQueue = [[NSOperationQueue alloc] init];
デリゲートキューが指定されている場合、クエリを実行するスレッドで実行ループを実行する必要はありません。
しかし、動作しません。ハンドラは依然としてメインスレッド上で実行されます。
質問:
バックグラウンドスレッドでハンドラを実行するためにGoogleドライブサービスを伝えるためにどのように?
Podfile再現するコードスニペット:どこかのアプリケーションで
pod 'GTMOAuth2'
pod 'GoogleAPIClient/Drive'
を:
#import "GTLDrive.h"
#import "GTMOAuth2Authentication.h"
...
- (void) applicationDidFinishLaunching:(NSNotification *) aNotification {
service = [[GTLServiceDrive alloc] init];
service.retryEnabled = YES;
service.authorizer = _authorizer //from GTMOAuth2WindowController
service.delegateQueue = [[NSOperationQueue alloc] init];
GTLDriveFile * tempadFolder = [GTLDriveFile object];
folder.name = @"folder-name";
folder.mimeType = @"application/vnd.google-apps.folder";
GTLQueryDrive * query = [GTLQueryDrive queryForFilesCreateWithObject: folder uploadParameters: nil];
[service executeQuery: query completionHandler:
^(GTLServiceTicket * ticket,
GTLDriveFile * updatedFile,
NSError * error) {
if ([NSThread isMainThread]) {
NSLog(@"This is a main thread!");
}
}
}