about page now gets information from service
This commit is contained in:
91
FestivalHelper/about/FESAboutViewController.m
Normal file
91
FestivalHelper/about/FESAboutViewController.m
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// FESAboutViewController.m
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 07/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FESAboutViewController.h"
|
||||
#import "FESDataProvider.h"
|
||||
#import "FESAboutEntry.h"
|
||||
|
||||
@interface FESAboutViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation FESAboutViewController
|
||||
|
||||
@synthesize aboutEntry;
|
||||
@synthesize aboutDescription;
|
||||
|
||||
|
||||
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
||||
{
|
||||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[FESDataProvider getDataFromServerForUrl:ABOUT_URL andProcessThemWith:^(NSData *data) {
|
||||
[self setupAboutFromJSONArray:data];
|
||||
[self performSelectorOnMainThread:@selector(setupAboutFields) withObject:nil waitUntilDone:NO];
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)setupAboutFromJSONArray:(NSData*)dataFromServerArray{
|
||||
NSError *error;
|
||||
|
||||
NSArray *arrayFromServer = [NSJSONSerialization JSONObjectWithData:dataFromServerArray options:0 error:&error];
|
||||
|
||||
if(error){
|
||||
NSLog(@"error parsing the json data from server with error description - %@", [error localizedDescription]);
|
||||
}
|
||||
else {
|
||||
for(NSDictionary *aboutData in arrayFromServer)
|
||||
{
|
||||
FESAboutEntry *entry = [[FESAboutEntry alloc] initWithJSONData:aboutData];
|
||||
self.aboutEntry = entry;
|
||||
break;
|
||||
}
|
||||
NSLog(@"success!");
|
||||
}
|
||||
}
|
||||
|
||||
-(void)setupAboutFields {
|
||||
if(aboutEntry != nil) {
|
||||
self.navigationItem.title = aboutEntry.aboutFestivalName;
|
||||
self.aboutDescription.text = aboutEntry.aboutDescription;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
{
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user