From 61cfcc173c9f6d16c07c943e72a69af68f47ac24 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Tue, 2 Sep 2014 20:00:02 +0200 Subject: [PATCH] first screen (schedule) now has the right information --- FestivalHelper.xcodeproj/project.pbxproj | 18 ++ .../xcdebugger/Breakpoints_v2.xcbkptlist | 87 +++++++++ FestivalHelper/Base.lproj/Main.storyboard | 64 ++++++- FestivalHelper/FestivalHelper-Info.plist | 2 - FestivalHelper/FestivalHelper-Prefix.pch | 6 + .../schedule/FESScheduleEntryCell.h | 17 ++ .../schedule/FESScheduleEntryCell.m | 34 ++++ .../schedule/FESScheduleTableViewController.h | 15 ++ .../schedule/FESScheduleTableViewController.m | 173 ++++++++++++++++++ tools/testbackend/sff2014/schedule.json | 17 +- 10 files changed, 422 insertions(+), 11 deletions(-) create mode 100644 FestivalHelper.xcodeproj/xcuserdata/hamo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 FestivalHelper/schedule/FESScheduleEntryCell.h create mode 100644 FestivalHelper/schedule/FESScheduleEntryCell.m create mode 100644 FestivalHelper/schedule/FESScheduleTableViewController.h create mode 100644 FestivalHelper/schedule/FESScheduleTableViewController.m diff --git a/FestivalHelper.xcodeproj/project.pbxproj b/FestivalHelper.xcodeproj/project.pbxproj index e88aa32..871b7b1 100644 --- a/FestivalHelper.xcodeproj/project.pbxproj +++ b/FestivalHelper.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 3068700719B2D6B1007E4A0E /* FESSCheduleEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 3068700619B2D6B1007E4A0E /* FESSCheduleEntry.m */; }; 3068700A19B2F826007E4A0E /* FESScheduleFilm.m in Sources */ = {isa = PBXBuildFile; fileRef = 3068700919B2F826007E4A0E /* FESScheduleFilm.m */; }; + 3068700D19B5AB16007E4A0E /* FESScheduleTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3068700C19B5AB16007E4A0E /* FESScheduleTableViewController.m */; }; + 3068701319B6301C007E4A0E /* FESScheduleEntryCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3068701219B6301C007E4A0E /* FESScheduleEntryCell.m */; }; 3CEA73BD19B1A86D00076FC5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CEA73BC19B1A86C00076FC5 /* Foundation.framework */; }; 3CEA73BF19B1A86D00076FC5 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CEA73BE19B1A86D00076FC5 /* CoreGraphics.framework */; }; 3CEA73C119B1A86D00076FC5 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CEA73C019B1A86D00076FC5 /* UIKit.framework */; }; @@ -39,6 +41,10 @@ 3068700619B2D6B1007E4A0E /* FESSCheduleEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FESSCheduleEntry.m; path = schedule/FESSCheduleEntry.m; sourceTree = ""; }; 3068700819B2F826007E4A0E /* FESScheduleFilm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FESScheduleFilm.h; path = schedule/FESScheduleFilm.h; sourceTree = ""; }; 3068700919B2F826007E4A0E /* FESScheduleFilm.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FESScheduleFilm.m; path = schedule/FESScheduleFilm.m; sourceTree = ""; }; + 3068700B19B5AB16007E4A0E /* FESScheduleTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FESScheduleTableViewController.h; path = schedule/FESScheduleTableViewController.h; sourceTree = ""; }; + 3068700C19B5AB16007E4A0E /* FESScheduleTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FESScheduleTableViewController.m; path = schedule/FESScheduleTableViewController.m; sourceTree = ""; }; + 3068701119B6301C007E4A0E /* FESScheduleEntryCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FESScheduleEntryCell.h; path = schedule/FESScheduleEntryCell.h; sourceTree = ""; }; + 3068701219B6301C007E4A0E /* FESScheduleEntryCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FESScheduleEntryCell.m; path = schedule/FESScheduleEntryCell.m; sourceTree = ""; }; 3CEA73B919B1A86C00076FC5 /* FestivalHelper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FestivalHelper.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3CEA73BC19B1A86C00076FC5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 3CEA73BE19B1A86D00076FC5 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -89,6 +95,10 @@ 3068700619B2D6B1007E4A0E /* FESSCheduleEntry.m */, 3068700819B2F826007E4A0E /* FESScheduleFilm.h */, 3068700919B2F826007E4A0E /* FESScheduleFilm.m */, + 3068700B19B5AB16007E4A0E /* FESScheduleTableViewController.h */, + 3068700C19B5AB16007E4A0E /* FESScheduleTableViewController.m */, + 3068701119B6301C007E4A0E /* FESScheduleEntryCell.h */, + 3068701219B6301C007E4A0E /* FESScheduleEntryCell.m */, ); name = schedule; sourceTree = ""; @@ -263,7 +273,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3068700D19B5AB16007E4A0E /* FESScheduleTableViewController.m in Sources */, 3CEA73C919B1A86D00076FC5 /* main.m in Sources */, + 3068701319B6301C007E4A0E /* FESScheduleEntryCell.m in Sources */, 3068700719B2D6B1007E4A0E /* FESSCheduleEntry.m in Sources */, 3CEA73CD19B1A86D00076FC5 /* FESAppDelegate.m in Sources */, 3068700A19B2F826007E4A0E /* FESScheduleFilm.m in Sources */, @@ -394,6 +406,11 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "FestivalHelper/FestivalHelper-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "LOCAL_URL=1", + "DEBUG=1", + "$(inherited)", + ); INFOPLIST_FILE = "FestivalHelper/FestivalHelper-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; @@ -408,6 +425,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "FestivalHelper/FestivalHelper-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "LOCAL_URL=0"; INFOPLIST_FILE = "FestivalHelper/FestivalHelper-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; diff --git a/FestivalHelper.xcodeproj/xcuserdata/hamo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/FestivalHelper.xcodeproj/xcuserdata/hamo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..ff02dde --- /dev/null +++ b/FestivalHelper.xcodeproj/xcuserdata/hamo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FestivalHelper/Base.lproj/Main.storyboard b/FestivalHelper/Base.lproj/Main.storyboard index 900e944..86dd82a 100644 --- a/FestivalHelper/Base.lproj/Main.storyboard +++ b/FestivalHelper/Base.lproj/Main.storyboard @@ -25,34 +25,82 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + diff --git a/FestivalHelper/FestivalHelper-Info.plist b/FestivalHelper/FestivalHelper-Info.plist index 83f2441..b18df65 100644 --- a/FestivalHelper/FestivalHelper-Info.plist +++ b/FestivalHelper/FestivalHelper-Info.plist @@ -43,8 +43,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight diff --git a/FestivalHelper/FestivalHelper-Prefix.pch b/FestivalHelper/FestivalHelper-Prefix.pch index 82a2bb4..2e4023f 100644 --- a/FestivalHelper/FestivalHelper-Prefix.pch +++ b/FestivalHelper/FestivalHelper-Prefix.pch @@ -14,3 +14,9 @@ #import #import #endif + +#if(URL_LOCAL==1) + #define SCHEDULE_URL @"http://127.0.0.1:8080/sff2014/schedule.json" +#else + #define SCHEDULE_URL @"http://localhost:8080/sff2014/schedule.json" +#endif diff --git a/FestivalHelper/schedule/FESScheduleEntryCell.h b/FestivalHelper/schedule/FESScheduleEntryCell.h new file mode 100644 index 0000000..5a41d04 --- /dev/null +++ b/FestivalHelper/schedule/FESScheduleEntryCell.h @@ -0,0 +1,17 @@ +// +// FESScheduleEntryCell.h +// FestivalHelper +// +// Created by Hamo Hapic on 02/09/14. +// Copyright (c) 2014 Senad Uka. All rights reserved. +// + +#import + +@interface FESScheduleEntryCell : UITableViewCell + +@property (weak, nonatomic)IBOutlet UILabel *scheduleDayOfWeek; +@property (weak, nonatomic)IBOutlet UILabel *scheduleDate; + + +@end diff --git a/FestivalHelper/schedule/FESScheduleEntryCell.m b/FestivalHelper/schedule/FESScheduleEntryCell.m new file mode 100644 index 0000000..1c5cdc1 --- /dev/null +++ b/FestivalHelper/schedule/FESScheduleEntryCell.m @@ -0,0 +1,34 @@ +// +// FESScheduleEntryCell.m +// FestivalHelper +// +// Created by Hamo Hapic on 02/09/14. +// Copyright (c) 2014 Senad Uka. All rights reserved. +// + +#import "FESScheduleEntryCell.h" + +@implementation FESScheduleEntryCell + +- (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 diff --git a/FestivalHelper/schedule/FESScheduleTableViewController.h b/FestivalHelper/schedule/FESScheduleTableViewController.h new file mode 100644 index 0000000..8289942 --- /dev/null +++ b/FestivalHelper/schedule/FESScheduleTableViewController.h @@ -0,0 +1,15 @@ +// +// FESScheduleTableViewController.h +// FestivalHelper +// +// Created by Hamo Hapic on 02/09/14. +// Copyright (c) 2014 Senad Uka. All rights reserved. +// + +#import + +@interface FESScheduleTableViewController : UITableViewController + +@property (strong)NSMutableArray *scheduleArray; + +@end diff --git a/FestivalHelper/schedule/FESScheduleTableViewController.m b/FestivalHelper/schedule/FESScheduleTableViewController.m new file mode 100644 index 0000000..3e339c1 --- /dev/null +++ b/FestivalHelper/schedule/FESScheduleTableViewController.m @@ -0,0 +1,173 @@ +// +// FESScheduleTableViewController.m +// FestivalHelper +// +// Created by Hamo Hapic on 02/09/14. +// Copyright (c) 2014 Senad Uka. All rights reserved. +// + +#import "FESScheduleTableViewController.h" +#import "FESSCheduleEntry.h" +#import "FESScheduleEntryCell.h" + +@interface FESScheduleTableViewController () + +@end + +@implementation FESScheduleTableViewController + +@synthesize scheduleArray; + + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.tableView.delegate = self; + self.tableView.dataSource = self; + [self getScheduleDataFromServer]; + + // 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 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + // Return the number of rows in the section. + 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{ + NSError *error; + self.scheduleArray = [[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.scheduleArray = [[NSMutableArray alloc] init]; + for(NSDictionary *scheduleData in arrayFromServer) + { + FESSCheduleEntry *entry = [[FESSCheduleEntry alloc] initWithJSONData:scheduleData]; + [self.scheduleArray addObject:entry]; + } + NSLog(@"success!"); + + } +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell *retrievedCell = [tableView dequeueReusableCellWithIdentifier:@"scheduleEntryCell" forIndexPath:indexPath]; + FESScheduleEntryCell *cell = (FESScheduleEntryCell *)retrievedCell; + + if(cell) + { + + //The beauty of this is that you have all your data in one object and grab WHATEVER you like + //This way in the future you can add another field without doing much. + FESSCheduleEntry *scheduleEntry = [scheduleArray objectAtIndex:indexPath.row]; + cell.scheduleDate.text = [scheduleEntry scheduleDate]; + cell.scheduleDayOfWeek.text = [scheduleEntry scheduleDayOfWeek]; + } + 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 diff --git a/tools/testbackend/sff2014/schedule.json b/tools/testbackend/sff2014/schedule.json index d01048d..2416522 100644 --- a/tools/testbackend/sff2014/schedule.json +++ b/tools/testbackend/sff2014/schedule.json @@ -2,7 +2,7 @@ { "id": 1, "dayOfWeek": "Fri", - "date": "15. Aug", + "date": "15. August", "year": "2014", "films": [ { @@ -13,6 +13,21 @@ "duration": "154'" } ] +}, +{ + "id": 2, + "dayOfWeek": "Sat", + "date": "16. August", + "year": "2014", + "films": [ + { + "id": 2, + "title": "Go go power rangers!", + "venue": "Summer Theatre HT Eronet", + "time": "20:31", + "duration": "166'" + } + ] } ] \ No newline at end of file