@@ -116,7 +116,7 @@ + (BOOL)checkAndNotifyError:(NSString *)key
116116 desc = @" no token" ;
117117 }
118118 if (desc != nil ) {
119- QNAsyncRun ( ^{
119+ QNAsyncRunInMain ( ^{
120120 completionHandler ([QNResponseInfo responseInfoWithInvalidArgument: desc], key, nil );
121121 });
122122 return YES ;
@@ -132,11 +132,18 @@ - (void)putData:(NSData *)data
132132 if ([QNUploadManager checkAndNotifyError: key token: token data: data file: nil complete: completionHandler]) {
133133 return ;
134134 }
135+
136+ QNUpCompletionHandler complete = ^(QNResponseInfo *info, NSString *key, NSDictionary *resp)
137+ {
138+ QNAsyncRunInMain ( ^{
139+ completionHandler (info, key, resp);
140+ });
141+ };
135142 QNFormUpload *up = [[QNFormUpload alloc ]
136143 initWithData: data
137144 withKey: key
138145 withToken: token
139- withCompletionHandler: completionHandler
146+ withCompletionHandler: complete
140147 withOption: option
141148 withHttpManager: _httpManager
142149 withConfiguration: _config];
@@ -159,7 +166,7 @@ - (void)putFile:(NSString *)filePath
159166 NSDictionary *fileAttr = [[NSFileManager defaultManager ] attributesOfItemAtPath: filePath error: &error];
160167
161168 if (error) {
162- QNAsyncRun ( ^{
169+ QNAsyncRunInMain ( ^{
163170 QNResponseInfo *info = [QNResponseInfo responseInfoWithFileError: error];
164171 completionHandler (info, key, nil );
165172 });
@@ -170,7 +177,7 @@ - (void)putFile:(NSString *)filePath
170177 UInt32 fileSize = [fileSizeNumber intValue ];
171178 NSData *data = [NSData dataWithContentsOfFile: filePath options: NSDataReadingMappedIfSafe error: &error];
172179 if (error) {
173- QNAsyncRun ( ^{
180+ QNAsyncRunInMain ( ^{
174181 QNResponseInfo *info = [QNResponseInfo responseInfoWithFileError: error];
175182 completionHandler (info, key, nil );
176183 });
@@ -183,7 +190,9 @@ - (void)putFile:(NSString *)filePath
183190
184191 QNUpCompletionHandler complete = ^(QNResponseInfo *info, NSString *key, NSDictionary *resp)
185192 {
186- completionHandler (info, key, resp);
193+ QNAsyncRunInMain ( ^{
194+ completionHandler (info, key, resp);
195+ });
187196 };
188197
189198 NSDate *modifyTime = fileAttr[NSFileModificationDate ];
0 commit comments