Skip to content

Instantly share code, notes, and snippets.

View mmesarina's full-sized avatar

Malena Mesarina mmesarina

View GitHub Profile
@mmesarina
mmesarina / gist:34c0af8889e2c339573f
Created December 13, 2014 15:16
Rottentomatoes API to load movies information
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);
}];
@mmesarina
mmesarina / gist:80d457e2714790bb8533
Created December 12, 2014 02:32
TipCalculator AppDelegate loads ViewController from mainStoryboard
- (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];
@mmesarina
mmesarina / gist:5bb03740f6ecd79139a7
Created October 18, 2014 04:31
RottenTomatoes MovieDetailController.m reload method
- (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;
@mmesarina
mmesarina / gist:e3e2260aee4cf3a66806
Last active August 29, 2015 14:07
RottenTomatoes Movie.m
- (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"]];
@mmesarina
mmesarina / gist:5ad8a3b2a9b34abd4747
Created October 18, 2014 04:20
RottenTomatoes prepareForSegue method
- (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;
@mmesarina
mmesarina / gist:ed2643f4ebcfdbb3ea25
Created October 18, 2014 04:19
RottenTomatoes ViewDidLoad of MoviesTableViewController
- (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];
@mmesarina
mmesarina / gist:cbf4c4c9b2cb15d5ca97
Created October 18, 2014 04:18
RottenTomatoes cellForRowAtIndex code
- (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];
@mmesarina
mmesarina / gist:de26b696f9d18bc64cbb
Created October 17, 2014 02:32
IOS_GUIDES WIKI
https://github.com/thecodepath/objc_ios_guides/wiki
@mmesarina
mmesarina / gist:5af2c0f5d6e316aebdab
Created October 17, 2014 02:31
AppDelegate bootstrapping rootViewController
- (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];
@mmesarina
mmesarina / gist:b4f1e9aead57e42ce9af
Created October 17, 2014 02:28
Using a Navigation Controller Example
https://github.com/thecodepath/objc_ios_guides/wiki/Using-Navigation-Controllers