Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add movie model, plugged into view to pass data

  • Loading branch information...
commit 8af31dd46af78fc1e3d68e39e4162ec52c0095e3 1 parent 8fcf3ef
@livando authored
View
7 MoviePad.xcodeproj/project.pbxproj
@@ -15,6 +15,7 @@
F514194E157702040025BABA /* DLAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F514194D157702040025BABA /* DLAppDelegate.m */; };
F5141951157702040025BABA /* DLViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F5141950157702040025BABA /* DLViewController.m */; };
F5141954157702040025BABA /* DLViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5141952157702040025BABA /* DLViewController.xib */; };
+ F51FFA061577F960007691FE /* DLMovie.m in Sources */ = {isa = PBXBuildFile; fileRef = F51FFA051577F960007691FE /* DLMovie.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -31,6 +32,8 @@
F514194F157702040025BABA /* DLViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DLViewController.h; sourceTree = "<group>"; };
F5141950157702040025BABA /* DLViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DLViewController.m; sourceTree = "<group>"; };
F5141953157702040025BABA /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DLViewController.xib; sourceTree = "<group>"; };
+ F51FFA041577F960007691FE /* DLMovie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DLMovie.h; sourceTree = "<group>"; };
+ F51FFA051577F960007691FE /* DLMovie.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DLMovie.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -83,6 +86,8 @@
F5141950157702040025BABA /* DLViewController.m */,
F5141952157702040025BABA /* DLViewController.xib */,
F5141944157702040025BABA /* Supporting Files */,
+ F51FFA041577F960007691FE /* DLMovie.h */,
+ F51FFA051577F960007691FE /* DLMovie.m */,
);
path = MoviePad;
sourceTree = "<group>";
@@ -164,6 +169,7 @@
F514194A157702040025BABA /* main.m in Sources */,
F514194E157702040025BABA /* DLAppDelegate.m in Sources */,
F5141951157702040025BABA /* DLViewController.m in Sources */,
+ F51FFA061577F960007691FE /* DLMovie.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -277,6 +283,7 @@
F5141959157702040025BABA /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
View
27 MoviePad/DLMovie.h
@@ -0,0 +1,27 @@
+//
+// DLMovie.h
+// MoviePad
+//
+// Created by Donald Livanec on 5/31/12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface DLMovie : NSObject
+@property (nonatomic, strong) NSString *title;
+@property (nonatomic, strong) NSString *year;
+@property (nonatomic, strong) NSString *mpaa_rating;
+@property (nonatomic, strong) NSString *runtime;
+@property (nonatomic, strong) NSString *critics_consensus;
+@property (nonatomic, strong) NSString *release_date;
+@property (nonatomic, strong) NSString *critics_rating;
+@property (nonatomic, strong) NSString *critics_score;
+@property (nonatomic, strong) NSString *audience_rating;
+@property (nonatomic, strong) NSString *audience_score;
+@property (nonatomic, strong) NSString *synopsis;
+@property (nonatomic, strong) NSString *thumbnail;
+@property (nonatomic, strong) NSString *profile;
+@property (nonatomic, strong) NSString *detailed;
+@property (nonatomic, strong) NSString *original;
+@end
View
13 MoviePad/DLMovie.m
@@ -0,0 +1,13 @@
+//
+// DLMovie.m
+// MoviePad
+//
+// Created by Donald Livanec on 5/31/12.
+// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#import "DLMovie.h"
+
+@implementation DLMovie
+@synthesize title, year, mpaa_rating, runtime, critics_consensus, release_date, critics_rating, critics_score, audience_score, audience_rating, synopsis, thumbnail, profile, detailed, original;
+@end
View
13 MoviePad/DLViewController.m
@@ -9,6 +9,7 @@
#define rTomatoesURL [NSURL URLWithString: @"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/box_office.json?limit=16&country=us&apikey=3atvjjwrmajgxybkxhqjh4pt"]
#import "DLViewController.h"
+#import "DLMovie.h"
@interface DLViewController ()
@property (nonatomic, strong) NSMutableArray *data;
@@ -39,11 +40,13 @@ - (void)fetchedData:(NSData *)responseData {
for (int i = 0; i < [boxOfficeMoviesData count]; i++){
NSString *title = [[boxOfficeMoviesData objectAtIndex:i]objectForKey:@"title"];
NSLog(@"%@", title);
- [data addObject:title];
+ DLMovie *movie = [[DLMovie alloc] init];
+ [movie setTitle:title];
+ [data addObject:movie];
}
[self setData:data];
[movieTable reloadData];
- [movieDetails setText: [[self data] objectAtIndex:0]];
+ [movieDetails setText: [[[self data] objectAtIndex:0] title]];
}
- (void)viewDidUnload
@@ -74,8 +77,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
- NSString *string = [[self data] objectAtIndex:[indexPath row]];
- [[cell textLabel] setText:string];
+ DLMovie *movie = [[self data] objectAtIndex:[indexPath row]];
+ [[cell textLabel] setText:[movie title]];
return cell;
}
@@ -84,7 +87,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"Click cell at index: %d", [indexPath row]);
- [movieDetails setText: [[self data] objectAtIndex:[indexPath row]]];
+ [movieDetails setText: [[[self data] objectAtIndex:[indexPath row]] title]];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
View
0  README.txt
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.