blob: 4fb0bc33a710ba3f42f85f2a545e05190f217e99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
|