// // 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 *)parentViewController sourceView:(UIView *)sourceView 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 *popopverPresenter = [alert popoverPresentationController]; if (popopverPresenter) { popopverPresenter.sourceView = sourceView; popopverPresenter.sourceRect = CGRectMake(CGRectGetMidX(sourceView.bounds), CGRectGetMidY(sourceView.bounds), 0, 0); } [parentViewController presentViewController:alert animated:YES completion:nil]; } @end