about page now gets information from service
This commit is contained in:
20
FestivalHelper/about/FESAboutEntry.h
Normal file
20
FestivalHelper/about/FESAboutEntry.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// FESAboutEntry.h
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 06/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface FESAboutEntry : NSObject
|
||||
|
||||
@property (assign) NSInteger aboutId;
|
||||
@property (strong) NSString *aboutFestivalName;
|
||||
@property (strong) NSString *aboutDescription;
|
||||
@property (strong) NSString *aboutAppRateUrl;
|
||||
|
||||
-(id)initWithJSONData:(NSDictionary*)aboutData;
|
||||
|
||||
@end
|
||||
31
FestivalHelper/about/FESAboutEntry.m
Normal file
31
FestivalHelper/about/FESAboutEntry.m
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// FESAboutEntry.m
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 06/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FESAboutEntry.h"
|
||||
|
||||
@implementation FESAboutEntry
|
||||
|
||||
@synthesize aboutId;
|
||||
@synthesize aboutAppRateUrl;
|
||||
@synthesize aboutDescription;
|
||||
@synthesize aboutFestivalName;
|
||||
|
||||
-(id)initWithJSONData:(NSDictionary*)aboutData {
|
||||
self = [super init];
|
||||
if(self){
|
||||
//NSLog(@"initWithJSONData method called");
|
||||
self.aboutId = [[aboutData objectForKey:@"id"] integerValue];
|
||||
self.aboutAppRateUrl = [aboutData objectForKey:@"appRateUrl"];
|
||||
self.aboutDescription = [aboutData objectForKey:@"description"];
|
||||
self.aboutFestivalName = [aboutData objectForKey:@"festivalName"];
|
||||
}
|
||||
return self;
|
||||
|
||||
};
|
||||
|
||||
@end
|
||||
21
FestivalHelper/about/FESAboutViewController.h
Normal file
21
FestivalHelper/about/FESAboutViewController.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// FESAboutViewController.h
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 07/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class FESAboutEntry;
|
||||
|
||||
@interface FESAboutViewController : UIViewController
|
||||
|
||||
|
||||
@property (strong)FESAboutEntry *aboutEntry;
|
||||
@property (weak, nonatomic)IBOutlet UITextView *aboutDescription;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
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