diff options
author | Vitaly Takmazov | 2021-02-10 19:42:20 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-02-10 19:47:34 +0300 |
commit | 7a969d40babccbb8bdddb254d03e74c638b354a8 (patch) | |
tree | a464df11e7d001e03ce78a2dab34d585085fe986 /Juick | |
parent | 2a122f9cddfd1759407bb115edbc9323035124ab (diff) |
Fix NSDictionary deserialization warnings
* added test target with deserialization test
Diffstat (limited to 'Juick')
-rw-r--r-- | Juick/Helpers/User+UIView.h | 19 | ||||
-rw-r--r-- | Juick/Helpers/User+UIView.m | 28 | ||||
-rw-r--r-- | Juick/Model/Message.m | 4 | ||||
-rw-r--r-- | Juick/Model/User.h | 2 | ||||
-rw-r--r-- | Juick/Model/User.m | 15 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/NewPostViewController.m | 1 |
7 files changed, 51 insertions, 19 deletions
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 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 diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index e58baae..d3bd8aa 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -15,6 +15,7 @@ #import "LoginViewController.h" #import "ThreadViewController.h" #import "BlogViewController.h" +#import "User+UIView.h" NSString* const messageCellIdentifier = @"messageCell"; diff --git a/Juick/ViewControllers/NewPostViewController.m b/Juick/ViewControllers/NewPostViewController.m index 990410b..03a27e3 100644 --- a/Juick/ViewControllers/NewPostViewController.m +++ b/Juick/ViewControllers/NewPostViewController.m @@ -9,6 +9,7 @@ #import "NewPostViewController.h" #import "MessagesViewController.h" #import "QuoteView.h" +#import "User+UIView.h" NSString * const NewMessageNotificationName = @"NewMessage"; NSString * const ReplyPostedNotificationName = @"ReplyPosted"; |