diff options
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 12 | ||||
-rw-r--r-- | Juick/APIClient.m | 24 |
2 files changed, 21 insertions, 15 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 78252e3..65abdb4 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -720,7 +720,7 @@ CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 135; + CURRENT_PROJECT_VERSION = 136; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -742,7 +742,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 135; + CURRENT_PROJECT_VERSION = 136; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Juick/Supporting Files/Juick-Prefix.pch"; @@ -770,7 +770,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 135; + CURRENT_PROJECT_VERSION = 136; DEBUG_INFORMATION_FORMAT = dwarf; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; @@ -802,7 +802,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 135; + CURRENT_PROJECT_VERSION = 136; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -883,7 +883,7 @@ CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - CURRENT_PROJECT_VERSION = 135; + CURRENT_PROJECT_VERSION = 136; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -912,7 +912,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 135; + CURRENT_PROJECT_VERSION = 136; DEBUG_INFORMATION_FORMAT = dwarf; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = KH4MX79ZK7; diff --git a/Juick/APIClient.m b/Juick/APIClient.m index 52b75ca..28c64ca 100644 --- a/Juick/APIClient.m +++ b/Juick/APIClient.m @@ -199,18 +199,24 @@ } NSURLSessionDataTask *task = [self.urlSession dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { - NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode; - if (!response || statusCode != 200) { - NSError *err = [NSError errorWithDomain:@"JuickErrorDomain" - code:statusCode - userInfo:nil]; + if (error) { [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - callback(nil, err); + callback(nil, error); }]; } else { - [[NSOperationQueue mainQueue] addOperationWithBlock:^{ - callback(data, error); - }]; + NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode; + if (!response || statusCode != 200) { + NSError *err = [NSError errorWithDomain:@"JuickErrorDomain" + code:statusCode + userInfo:nil]; + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + callback(nil, err); + }]; + } else { + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + callback(data, error); + }]; + } } }]; [self.backgroundQueue addOperationWithBlock:^{ |