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/Model/Message.m | 4 ++-- Juick/Model/User.h | 2 -- Juick/Model/User.m | 15 --------------- 3 files changed, 2 insertions(+), 19 deletions(-) (limited to 'Juick/Model') diff --git a/Juick/Model/Message.m b/Juick/Model/Message.m index d39be54..0319543 100644 --- a/Juick/Model/Message.m +++ b/Juick/Model/Message.m @@ -20,8 +20,8 @@ message.repliesBy = jsonData[@"repliesby"]; message.user = [User fromJSON:jsonData[@"user"]]; message.timestamp = jsonData[@"timestamp"]; - message.service = jsonData[@"service"]; - message.unread = jsonData[@"unread"]; + message.service = [[jsonData objectForKey:@"service"] boolValue]; + message.unread = [[jsonData objectForKey:@"unread"] boolValue]; message.tags = jsonData[@"tags"]; NSMutableArray *entitiesArray = [NSMutableArray new]; for (NSDictionary *entityData in jsonData[@"entities"]) { diff --git a/Juick/Model/User.h b/Juick/Model/User.h index cb63ebc..5393c3d 100644 --- a/Juick/Model/User.h +++ b/Juick/Model/User.h @@ -18,6 +18,4 @@ + (User *) fromJSON:(NSDictionary *)jsonData; -+ (void) throwUnableToLogin:(UIViewController *)view error:(NSError *)error path:(NSString *)path params:(NSDictionary *)params; - @end diff --git a/Juick/Model/User.m b/Juick/Model/User.m index ee3cce8..2401c7e 100644 --- a/Juick/Model/User.m +++ b/Juick/Model/User.m @@ -21,19 +21,4 @@ return user; } -+(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