summaryrefslogtreecommitdiff
path: root/Juick/Model/Attachment.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Model/Attachment.m')
-rw-r--r--Juick/Model/Attachment.m29
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