venues now have correct information on them
This commit is contained in:
@@ -89,25 +89,25 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="108"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VMV-Mw-Ifg">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="20:50" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VMV-Mw-Ifg">
|
||||
<rect key="frame" x="20" y="20" width="42" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qhF-PW-R8w">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" misplaced="YES" text="Neki film" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qhF-PW-R8w">
|
||||
<rect key="frame" x="70" y="20" width="236" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yQC-zo-ba8">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Neko kino" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yQC-zo-ba8">
|
||||
<rect key="frame" x="70" y="48" width="236" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5wK-D2-9Nf">
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="150'" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5wK-D2-9Nf">
|
||||
<rect key="frame" x="70" y="77" width="42" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
@@ -143,24 +143,56 @@
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="2Po-QA-1an" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1894" y="-235"/>
|
||||
<point key="canvasLocation" x="1895" y="-242"/>
|
||||
</scene>
|
||||
<!--Table View Controller - Root View Controller-->
|
||||
<!--Venues Table View Controller - Venues-->
|
||||
<scene sceneID="CX5-hP-Yrk">
|
||||
<objects>
|
||||
<tableViewController id="OwN-NY-lQV" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="fiy-kO-qOW">
|
||||
<tableViewController id="OwN-NY-lQV" customClass="FESVenuesTableViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="88" sectionHeaderHeight="22" sectionFooterHeight="22" id="fiy-kO-qOW">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="pRA-XH-MNZ">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="venueEntryCell" rowHeight="88" id="pRA-XH-MNZ" customClass="FESVenueEntryCell">
|
||||
<rect key="frame" x="0.0" y="86" width="320" height="88"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="pRA-XH-MNZ" id="8Lb-ac-tEa">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="87"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Summer Theatre HT Eronet" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r39-y9-TCo">
|
||||
<rect key="frame" x="20" y="20" width="280" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Gimnazijska bb" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LMT-fD-pgR">
|
||||
<rect key="frame" x="20" y="49" width="217" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="3.000" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="P0F-Kj-f6N">
|
||||
<rect key="frame" x="257" y="49" width="43" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="P0F-Kj-f6N" firstAttribute="leading" secondItem="LMT-fD-pgR" secondAttribute="trailing" constant="20" id="259-5g-8ST"/>
|
||||
<constraint firstItem="LMT-fD-pgR" firstAttribute="leading" secondItem="8Lb-ac-tEa" secondAttribute="leading" constant="20" id="Auk-fz-VIf"/>
|
||||
<constraint firstAttribute="trailing" secondItem="r39-y9-TCo" secondAttribute="trailing" constant="20" id="NPk-Wf-nvl"/>
|
||||
<constraint firstAttribute="trailing" secondItem="P0F-Kj-f6N" secondAttribute="trailing" constant="20" id="Zux-mN-h5D"/>
|
||||
<constraint firstItem="r39-y9-TCo" firstAttribute="leading" secondItem="8Lb-ac-tEa" secondAttribute="leading" constant="20" id="t43-fZ-5TG"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="venueAddress" destination="LMT-fD-pgR" id="dwO-ag-hWh"/>
|
||||
<outlet property="venueCapacity" destination="P0F-Kj-f6N" id="aZT-si-Jyv"/>
|
||||
<outlet property="venueName" destination="r39-y9-TCo" id="1GJ-KA-bxa"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
@@ -168,7 +200,7 @@
|
||||
<outlet property="delegate" destination="OwN-NY-lQV" id="StC-gP-bLn"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Root View Controller" id="aOU-AZ-Itd"/>
|
||||
<navigationItem key="navigationItem" title="Venues" id="aOU-AZ-Itd"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="3Sp-V5-4ky" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
#endif
|
||||
|
||||
#if(URL_LOCAL==1)
|
||||
#define SCHEDULE_URL @"http://127.0.0.1:8080/sff2014/schedule.json"
|
||||
#define SCHEDULE_URL @"http://127.0.0.1:8080/sff2014/schedule.json?local"
|
||||
#define VENUES_URL @"http://127.0.0.1:8080/sff2014/venues.json?local"
|
||||
#else
|
||||
#define SCHEDULE_URL @"http://localhost:8080/sff2014/schedule.json"
|
||||
#define SCHEDULE_URL @"http://localhost:8080/sff2014/schedule.json?remote"
|
||||
#define VENUES_URL @"http://localhost:8080/sff2014/venues.json?remote"
|
||||
#endif
|
||||
|
||||
15
FestivalHelper/common/FESDataProvider.h
Normal file
15
FestivalHelper/common/FESDataProvider.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// FESDataProvider.h
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface FESDataProvider : NSObject
|
||||
|
||||
+(void)getDataFromServerForUrl:(NSString *)urlString andProcessThemWith:(void (^)(NSData *data))block;
|
||||
|
||||
@end
|
||||
27
FestivalHelper/common/FESDataProvider.m
Normal file
27
FestivalHelper/common/FESDataProvider.m
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// FESDataProvider.m
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FESDataProvider.h"
|
||||
|
||||
@implementation FESDataProvider
|
||||
|
||||
+(void)getDataFromServerForUrl:(NSString *)urlString andProcessThemWith:(void (^)(NSData *data))block {
|
||||
NSLog(@"Getting data from: %@" , urlString);
|
||||
NSURL *url = [[NSURL alloc] initWithString:urlString];
|
||||
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
|
||||
if(connectionError) {
|
||||
NSLog(@"Error getting %@ data from url: - %@", urlString, [connectionError localizedDescription]);
|
||||
}
|
||||
else {
|
||||
NSLog(@"Parsing data.");
|
||||
block(data);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
|
||||
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "FESSCheduleEntry.h"
|
||||
#import "FESScheduleEntryCell.h"
|
||||
#import "FESScheduleFilmsViewController.h"
|
||||
#import "FESDataProvider.h"
|
||||
|
||||
@interface FESScheduleTableViewController ()
|
||||
|
||||
@@ -34,7 +35,10 @@
|
||||
[super viewDidLoad];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
[self getScheduleDataFromServer];
|
||||
[FESDataProvider getDataFromServerForUrl:SCHEDULE_URL andProcessThemWith:^(NSData *data) {
|
||||
[self setupScheduleFromJSONArray:data];
|
||||
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
|
||||
}];
|
||||
|
||||
// Uncomment the following line to preserve selection between presentations.
|
||||
// self.clearsSelectionOnViewWillAppear = NO;
|
||||
@@ -62,25 +66,7 @@
|
||||
return [self.scheduleArray count];
|
||||
}
|
||||
|
||||
-(void)getScheduleDataFromServer {
|
||||
|
||||
NSLog(@"Getting data");
|
||||
|
||||
NSURL *url = [[NSURL alloc] initWithString:SCHEDULE_URL];
|
||||
[NSURLConnection sendAsynchronousRequest:[[NSURLRequest alloc] initWithURL:url] queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
|
||||
if(connectionError) {
|
||||
NSLog(@"Error getting %@ schedule data: - %@", SCHEDULE_URL, [connectionError localizedDescription]);
|
||||
}
|
||||
else {
|
||||
NSLog(@"Parsing data.");
|
||||
[self setupScheduleFromJSONArray:data];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)setupScheduleFromJSONArray:(NSData*)dataFromServerArray{
|
||||
|
||||
21
FestivalHelper/venues/FESVenueEntry.h
Normal file
21
FestivalHelper/venues/FESVenueEntry.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// FESVenueEntry.h
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface FESVenueEntry : NSObject
|
||||
|
||||
-(id)initWithJSONData:(NSDictionary*)data;
|
||||
|
||||
@property (assign) NSInteger venueEntryId;
|
||||
@property (strong) NSString *venueName;
|
||||
@property (strong) NSString *venueAddress;
|
||||
@property (strong) NSString *venueCapacity;
|
||||
|
||||
|
||||
@end
|
||||
32
FestivalHelper/venues/FESVenueEntry.m
Normal file
32
FestivalHelper/venues/FESVenueEntry.m
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// FESVenueEntry.m
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FESVenueEntry.h"
|
||||
|
||||
@implementation FESVenueEntry
|
||||
|
||||
@synthesize venueEntryId;
|
||||
@synthesize venueName;
|
||||
@synthesize venueAddress;
|
||||
@synthesize venueCapacity;
|
||||
|
||||
-(id)initWithJSONData:(NSDictionary*)data{
|
||||
self = [super init];
|
||||
if(self){
|
||||
//NSLog(@"initWithJSONData method called");
|
||||
self.venueEntryId = [[data objectForKey:@"id"] integerValue];
|
||||
self.venueName = [data objectForKey:@"name"];
|
||||
self.venueAddress = [data objectForKey:@"address"];
|
||||
self.venueCapacity = [data objectForKey:@"capacity"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
18
FestivalHelper/venues/FESVenueEntryCell.h
Normal file
18
FestivalHelper/venues/FESVenueEntryCell.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// FESVenueEntryCell.h
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FESVenueEntryCell : UITableViewCell
|
||||
|
||||
@property (weak, nonatomic)IBOutlet UILabel *venueName;
|
||||
@property (weak, nonatomic)IBOutlet UILabel *venueAddress;
|
||||
@property (weak, nonatomic)IBOutlet UILabel *venueCapacity;
|
||||
|
||||
|
||||
@end
|
||||
38
FestivalHelper/venues/FESVenueEntryCell.m
Normal file
38
FestivalHelper/venues/FESVenueEntryCell.m
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// FESVenueEntryCell.m
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FESVenueEntryCell.h"
|
||||
|
||||
@implementation FESVenueEntryCell
|
||||
|
||||
@synthesize venueCapacity;
|
||||
@synthesize venueAddress;
|
||||
@synthesize venueName;
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
|
||||
{
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
@end
|
||||
15
FestivalHelper/venues/FESVenuesTableViewController.h
Normal file
15
FestivalHelper/venues/FESVenuesTableViewController.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// FESVenuesTableViewController.h
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FESVenuesTableViewController : UITableViewController
|
||||
|
||||
@property (strong)NSMutableArray *venuesArray;
|
||||
|
||||
@end
|
||||
155
FestivalHelper/venues/FESVenuesTableViewController.m
Normal file
155
FestivalHelper/venues/FESVenuesTableViewController.m
Normal file
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// FESVenuesTableViewController.m
|
||||
// FestivalHelper
|
||||
//
|
||||
// Created by Hamo Hapic on 04/09/14.
|
||||
// Copyright (c) 2014 Senad Uka. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FESVenuesTableViewController.h"
|
||||
#import "FESVenueEntry.h"
|
||||
#import "FESDataProvider.h"
|
||||
#import "FESVenueEntryCell.h"
|
||||
|
||||
@interface FESVenuesTableViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation FESVenuesTableViewController
|
||||
|
||||
@synthesize venuesArray;
|
||||
|
||||
- (id)initWithStyle:(UITableViewStyle)style
|
||||
{
|
||||
self = [super initWithStyle:style];
|
||||
if (self) {
|
||||
// Custom initialization
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
[FESDataProvider getDataFromServerForUrl:VENUES_URL andProcessThemWith:^(NSData *data) {
|
||||
[self setupScheduleFromJSONArray:data];
|
||||
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
|
||||
}];
|
||||
|
||||
// Uncomment the following line to preserve selection between presentations.
|
||||
// self.clearsSelectionOnViewWillAppear = NO;
|
||||
|
||||
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
|
||||
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
// Return the number of sections.
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
// Return the number of rows in the section.
|
||||
return [venuesArray count];
|
||||
}
|
||||
|
||||
|
||||
-(void)setupScheduleFromJSONArray:(NSData*)dataFromServerArray{
|
||||
NSError *error;
|
||||
self.venuesArray = [[NSMutableArray alloc] init];
|
||||
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 {
|
||||
self.venuesArray = [[NSMutableArray alloc] init];
|
||||
for(NSDictionary *venueData in arrayFromServer)
|
||||
{
|
||||
FESVenueEntry *entry = [[FESVenueEntry alloc] initWithJSONData:venueData];
|
||||
[self.venuesArray addObject:entry];
|
||||
}
|
||||
NSLog(@"success!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell *retrievedCell = [tableView dequeueReusableCellWithIdentifier:@"venueEntryCell" forIndexPath:indexPath];
|
||||
FESVenueEntryCell *cell = (FESVenueEntryCell *)retrievedCell;
|
||||
|
||||
FESVenueEntry *venueEntry = [venuesArray objectAtIndex:indexPath.row];
|
||||
|
||||
cell.venueName.text = venueEntry.venueName;
|
||||
cell.venueAddress.text = venueEntry.venueAddress;
|
||||
cell.venueCapacity.text = venueEntry.venueCapacity;
|
||||
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Override to support conditional editing of the table view.
|
||||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// Return NO if you do not want the specified item to be editable.
|
||||
return YES;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// Override to support editing the table view.
|
||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (editingStyle == UITableViewCellEditingStyleDelete) {
|
||||
// Delete the row from the data source
|
||||
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
|
||||
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// Override to support rearranging the table view.
|
||||
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// Override to support conditional rearranging of the table view.
|
||||
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
// Return NO if you do not want the item to be re-orderable.
|
||||
return YES;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
#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