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/Attachment.m | |
parent | 4851a21c41488a6f0c01e60f1bd1472846f816bf (diff) |
SwiftUI WIP
Diffstat (limited to 'Juick/Model/Attachment.m')
-rw-r--r-- | Juick/Model/Attachment.m | 29 |
1 files changed, 16 insertions, 13 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 |