-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilm.m
More file actions
40 lines (35 loc) · 1.32 KB
/
Film.m
File metadata and controls
40 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Film.m
// Lesson20
//
// Created by Azat Almeev on 27.04.16.
// Copyright © 2016 Azat Almeev. All rights reserved.
//
#import "Film.h"
@implementation Film
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{ @"ID" : @"id",
@"name" : @"nameRU",
@"imageURL" : @"posterURL",
@"premiereDate" : @"premiereRU",
@"rating" : @"ratingData.rating",
@"country" : @"country",
@"filmLength" : @"filmLength",
@"ratingMPAA" : @"ratingMPAA",
@"filmDescription" : @"description",
@"genre" : @"genre",
@"slogan" : @"slogan" };
}
+ (NSValueTransformer *)premiereDateJSONTransformer {
return [MTLValueTransformer transformerUsingForwardBlock:^id(NSString *dateString, BOOL *success, NSError *__autoreleasing *error) {
NSDateFormatter *dateFormatter = [NSDateFormatter new];
dateFormatter.dateFormat = @"dd.MM.yyyy";
NSDate *date = [dateFormatter dateFromString:dateString];
dateFormatter.dateStyle = NSDateFormatterLongStyle;
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"ru"];
return [dateFormatter stringFromDate:date];
} reverseBlock:^id(id value, BOOL *success, NSError *__autoreleasing *error) {
return value;
}];
}
@end