-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilm.m
More file actions
37 lines (32 loc) · 1.18 KB
/
Film.m
File metadata and controls
37 lines (32 loc) · 1.18 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
//
// 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 @{ @"name" : @"nameRU",
@"imageURL" : @"posterURL",
@"premiereDate" : @"premiereRU" ,
@"rating" : @"rating",
@"length" : @"cinemaHallCount",
@"fid" : @"id",
@"country" : @"country",
@"year":@"year"};
}
+ (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