Dispatching callbacks to main thread for JSON requests
This commit is contained in:
parent
abc04440f7
commit
9a78cc54cd
1 changed files with 7 additions and 3 deletions
|
|
@ -84,11 +84,15 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (failure) {
|
if (failure) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
failure(request, response, error);
|
failure(request, response, error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if ([data length] == 0) {
|
} else if ([data length] == 0) {
|
||||||
if (success) {
|
if (success) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
success(request, response, nil);
|
success(request, response, nil);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch_async(json_request_operation_processing_queue(), ^(void) {
|
dispatch_async(json_request_operation_processing_queue(), ^(void) {
|
||||||
|
|
@ -104,7 +108,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
||||||
JSON = [[JSONDecoder decoder] objectWithData:data error:&JSONError];
|
JSON = [[JSONDecoder decoder] objectWithData:data error:&JSONError];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dispatch_sync(dispatch_get_main_queue(), ^(void) {
|
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
||||||
if (JSONError) {
|
if (JSONError) {
|
||||||
if (failure) {
|
if (failure) {
|
||||||
failure(request, response, JSONError);
|
failure(request, response, JSONError);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue