Skip to content

Instantly share code, notes, and snippets.

@xandrucea
Last active December 16, 2015 03:09
Show Gist options
  • Save xandrucea/5367673 to your computer and use it in GitHub Desktop.
Save xandrucea/5367673 to your computer and use it in GitHub Desktop.
//
// TumblrCheckViewController.m
// TumblrCheck
//
// Created by Alexandru Ciocea on 11.04.13.
// Copyright (c) 2013 ImprovingSkills. All rights reserved.
//
#define kAsyncModus dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define kTumblURL [NSURL URLWithString: @"http://trainbrainstorm.tumblr.com/api/read/json"]
#define kAnotherURL [NSURL URLWithString: @"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]
#import "TumblrCheckViewController.h"
#import "TumblrApiCall.h"
@interface TumblrCheckViewController ()
@end
@implementation TumblrCheckViewController
//NSString *const URL = ;
TumblrApiCall *apiCall;
NSMutableArray *results;
- (void)viewDidLoad
{
[super viewDidLoad];
// get elements of json
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// fetch data from predefined url
NSData *data = [NSData dataWithContentsOfURL: kTvWerbungURLGetParameter];
[self performSelectorInBackground:@selector(fetchData:)
withObject:data];
dispatch_async(dispatch_get_main_queue(), ^{
initiatedChannels = [[NSMutableArray alloc] init];
[self jsonToTvChannels];
[self.channelTableView reloadData];
});
});
}
- (void)fetchedData:(NSData *)responseData{
NSError *error;
NSDictionary *json =
[NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSLog(@"JSON: %@", json);
results = [json objectForKey:@"posts-total"];
NSLog(@"Results: %@", results);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment