I'm new to programming in general so please forgive my ignorance. If anyone can point me in the right direction it would be greatly appreciated.
I followed this tutorial for AFNetworking (http://www.raywenderlich.com/30445/afnetworking-crash-course) and have it working in my own project to parse JSON from the web.
I have yet to figure out how to transfer THAT data to a different UIViewController. I have seen Passing Data between View Controllers and other related questions to no avail.
I've tried using Delegates&Protocols/Singletons/GlobalVariables/ReferencingClasses and I can get them to work for other non JSON related material, when I NSLog the value it is always NULL. (Also the JSON data will be changing, and I read somewhere that some of these options are not mutable)
The tutorial seems to me to use custom NSDictionary classes to store the JSON Data and pass it over using prepareForSegue: but as far as I know, that is a Storyboard only method. I'm using nib files. Should I just switch my whole project to Storyboard style or is there a way to do this with Nibs/Xibs?
Thank you for taking the time to read this. The last thing I wanted to do is trouble you with a question but I've been stuck for a while now.
EDIT: I have retrieved JSON Data on the ViewController I preformed the request on, but it does not transfer over to other ViewControllers, and I feel it would be bad practice to request JSON data on every new Controller I need it on.
EDIT2 Here is some Code (I can post more if you want)
-(void)jsonData {
NSLog(@"Loading JSON...");
NSURL *url = [NSURL URLWithString:@"http://fillerCode.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"station",@"1",@"previous_song", nil];
NSURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"/scripts/MoreFillerCode" parameters:params];
AFJSONRequestOperation *operation =
[AFJSONRequestOperation JSONRequestOperationWithRequest: request
// JSON SUCCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"Getting Next Song...");
self.get_next_song = (NSDictionary *)JSON;
RightViewController *rightViewController = [[RightViewController alloc] init];
rightViewController.get_next_song = self.get_next_song;
[self updateViewStuff];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Data"
message:[NSString stringWithFormat:@"%@",error]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[av show];
NSLog(@"Operation Failed");
}];
[operation start];
NSLog(@"JSON Operation Started");
}