diff options
author | Vitaly Takmazov | 2020-09-17 00:46:27 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2020-12-10 18:59:55 +0300 |
commit | cf97b1cd43a91725e0419a953815287fde0bf70f (patch) | |
tree | 82961197cf7fa1bfa40550748ddd309e5e4d38c3 /Juick/Model | |
parent | 4851a21c41488a6f0c01e60f1bd1472846f816bf (diff) |
SwiftUI WIP
Diffstat (limited to 'Juick/Model')
-rw-r--r-- | Juick/Model/Attachment.m | 29 | ||||
-rw-r--r-- | Juick/Model/Message.h | 12 | ||||
-rw-r--r-- | Juick/Model/Message.m | 2 | ||||
-rw-r--r-- | Juick/Model/User.h | 1 |
4 files changed, 26 insertions, 18 deletions
diff --git a/Juick/Model/Attachment.m b/Juick/Model/Attachment.m index 006b72e..e0de2ca 100644 --- a/Juick/Model/Attachment.m +++ b/Juick/Model/Attachment.m @@ -11,20 +11,23 @@ @implementation Attachment +(Attachment *) fromJSON:(NSDictionary *)jsonData { - Attachment *attachment = [Attachment new]; - attachment.url = jsonData[@"url"]; - attachment.width = jsonData[@"width"]; - attachment.height = jsonData[@"height"]; - if (jsonData[@"small"]) { - attachment.small = [Attachment fromJSON:jsonData[@"small"]]; + if (jsonData[@"url"]) { + Attachment *attachment = [Attachment new]; + attachment.url = jsonData[@"url"]; + attachment.width = jsonData[@"width"]; + attachment.height = jsonData[@"height"]; + if (jsonData[@"small"]) { + attachment.small = [Attachment fromJSON:jsonData[@"small"]]; + } + if (jsonData[@"medium"]) { + attachment.medium = [Attachment fromJSON:jsonData[@"medium"]]; + } + if (jsonData[@"thumbnail"]) { + attachment.thumbnail = [Attachment fromJSON:jsonData[@"thumbnail"]]; + } + return attachment; } - if (jsonData[@"medium"]) { - attachment.medium = [Attachment fromJSON:jsonData[@"medium"]]; - } - if (jsonData[@"thumbnail"]) { - attachment.thumbnail = [Attachment fromJSON:jsonData[@"thumbnail"]]; - } - return attachment; + return nil; } @end diff --git a/Juick/Model/Message.h b/Juick/Model/Message.h index 33d9911..5c85b1e 100644 --- a/Juick/Model/Message.h +++ b/Juick/Model/Message.h @@ -11,22 +11,26 @@ #import "Attachment.h" #import "Entity.h" +NS_ASSUME_NONNULL_BEGIN + @interface Message : NSObject -@property NSNumber *mid; -@property NSNumber *rid; +@property NSNumber * _Nonnull mid; +@property NSNumber * _Nullable rid; @property User *user; -@property NSString *text; +@property NSString * _Nullable text; @property NSArray<NSString *> *tags; @property NSArray<Entity *> *entities; @property NSString *timestamp; @property NSString *attach; @property NSString *repliesBy; @property NSNumber *repliesCount; -@property Attachment *attachment; +@property Attachment * _Nullable attachment; @property BOOL service; @property BOOL unread; +(Message *) fromJSON:(NSDictionary *)jsonData; @end + +NS_ASSUME_NONNULL_END diff --git a/Juick/Model/Message.m b/Juick/Model/Message.m index d39be54..afc499e 100644 --- a/Juick/Model/Message.m +++ b/Juick/Model/Message.m @@ -13,7 +13,7 @@ + (Message *) fromJSON:(NSDictionary *)jsonData { Message * message = [Message new]; message.mid = jsonData[@"mid"]; - message.rid = jsonData[@"rid"]; + message.rid = [NSNumber numberWithInt:jsonData[@"rid"]]; message.text = jsonData[@"body"]; message.attach = jsonData[@"photo"][@"small"]; message.repliesCount = jsonData[@"replies"]; diff --git a/Juick/Model/User.h b/Juick/Model/User.h index 4bbf332..5941a90 100644 --- a/Juick/Model/User.h +++ b/Juick/Model/User.h @@ -7,6 +7,7 @@ // @import Foundation; +@import UIKit; @interface User : NSObject @property (nonatomic, strong) NSString *uname; |