From 7a969d40babccbb8bdddb254d03e74c638b354a8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 10 Feb 2021 19:42:20 +0300 Subject: Fix NSDictionary deserialization warnings * added test target with deserialization test --- Juick/Helpers/User+UIView.h | 19 +++++++++++++++++++ Juick/Helpers/User+UIView.m | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Juick/Helpers/User+UIView.h create mode 100644 Juick/Helpers/User+UIView.m (limited to 'Juick/Helpers') diff --git a/Juick/Helpers/User+UIView.h b/Juick/Helpers/User+UIView.h new file mode 100644 index 0000000..d2f75ce --- /dev/null +++ b/Juick/Helpers/User+UIView.h @@ -0,0 +1,19 @@ +// +// User+User_UIView.h +// Juick +// +// Created by Vitaly Takmazov on 10.02.2021. +// Copyright © 2021 com.juick. All rights reserved. +// + +#import "User.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface User (UIView) + ++ (void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary * _Nullable)params; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Juick/Helpers/User+UIView.m b/Juick/Helpers/User+UIView.m new file mode 100644 index 0000000..4fb0bc3 --- /dev/null +++ b/Juick/Helpers/User+UIView.m @@ -0,0 +1,28 @@ +// +// User+User_UIView.m +// Juick +// +// Created by Vitaly Takmazov on 10.02.2021. +// Copyright © 2021 com.juick. All rights reserved. +// + +#import "User+UIView.h" + +@implementation User (UIView) + ++(void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary *)params { + UIAlertController *alert = [UIAlertController new]; + NSString *title = error.userInfo[@"url"] ? error.userInfo[@"url"] : @"Something went wrong"; + [alert setTitle:title]; + [alert setMessage:[NSString stringWithFormat:@"err: %@, path: %@, params: %@", error.localizedDescription, path, params]]; + [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]]; + UIPopoverPresentationController *popover = [alert popoverPresentationController]; + if (popover) { + popover.sourceView = view.view; + popover.sourceRect = CGRectMake(CGRectGetMidX(view.view.bounds), CGRectGetMidY(view.view.bounds), 0, 0); + popover.permittedArrowDirections = UIPopoverArrowDirectionDown; + } + [view presentViewController:alert animated:YES completion:nil]; +} + +@end -- cgit v1.2.3