This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *url = @"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=ws32mxpd653h5c8zqfvksxw9"; | |
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { | |
id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; | |
self.movies = object[@"movies"]; | |
[self.tableView reloadData]; | |
NSLog(@"%@", object); | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; | |
TipViewController *tipViewController = [storyboard instantiateInitialViewController]; | |
//self.window.backgroundColor = [UIColor whiteColor]; | |
self.window.rootViewController = tipViewController; | |
[self.window makeKeyAndVisible]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)reload{ | |
self.movieTitle.text = self.movieDetail.title; | |
self.synopsis.text = self.movieDetail.sypnopsis; | |
self.cast.text = self.movieDetail.cast; | |
self.rating.text = self.movieDetail.ratings; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (id)initWithDictionary: (NSDictionary*)dictionary { | |
self = [super init]; | |
if (self ) { | |
self.title = dictionary[@"title"]; | |
self.synopsis = dictionary[@"synopsis"]; | |
NSMutableArray *castArray = [[NSMutableArray alloc] init]; | |
NSArray *abridged_cast = dictionary[@"abridged_cast"]; | |
for (id dict in abridged_cast) { | |
[castArray addObject:dict[@"name"]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
if ([segue.identifier isEqualToString:@"showMovieDetailView"]) { | |
MovieDetailViewController *movieDetailController = segue.destinationViewController; | |
// Pass movie data to detail controller | |
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; // get the row number | |
Movie *movieDetail = [[Movie alloc] initWithDictionary:self.movies[indexPath.row]]; | |
movieDetailController.movieDetail = movieDetail; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
NSString *url = @"http://api.rottentomatoes.com/api/public/v1.0/lists/movies/in_theaters.json?apikey=ws32mxpd653h5c8zqfvksxw9"; | |
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { | |
id object = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
NSLog(@"Number of Movies = %lu", (unsigned long)self.movies.count); | |
// Configure the cell... | |
//UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil | |
MovieCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyMovieCell"]; | |
NSDictionary *movie = self.movies[indexPath.row]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/thecodepath/objc_ios_guides/wiki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
TestViewController *vc = [[TestViewController alloc] init]; | |
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc]; | |
self.window.rootViewController = nvc; | |
self.window.backgroundColor = [UIColor whiteColor]; | |
[self.window makeKeyAndVisible]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/thecodepath/objc_ios_guides/wiki/Using-Navigation-Controllers |
NewerOlder