-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovies.m
More file actions
51 lines (35 loc) · 1.03 KB
/
Movies.m
File metadata and controls
51 lines (35 loc) · 1.03 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
41
42
43
44
45
46
47
48
49
50
51
//
// Movies.m
// Rotten Tomatoes
//
// Created by Jacob Cho on 2014-07-18.
// Copyright (c) 2014 Jacob Cho. All rights reserved.
//
#import "Movies.h"
@implementation Movies
-(id) initWithTitle:(NSString *)title {
self = [super init];
if (self) {
self.title = title;
self.thumbnail = nil;
}
return self;
}
+ (id) movieWithTitle:(NSString *)title {
return [[self alloc] initWithTitle:title];
}
- (NSURL *) thumbnailURL {
return [NSURL URLWithString:self.thumbnail];
}
- (NSURL *) detailPosterURL {
NSString *detailPoster = [self.thumbnail stringByReplacingOccurrencesOfString:@"tmb" withString:@"det"];
return [NSURL URLWithString:detailPoster];
}
- (NSString *) formattedDate {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate *tempDate = [dateFormatter dateFromString:self.date];
[dateFormatter setDateFormat:@"EE, MMMM dd"];
return [dateFormatter stringFromDate:tempDate];
}
@end