added entry and film model

This commit is contained in:
Hamo Hapic
2014-09-01 16:58:20 +02:00
parent 8eafca63cf
commit e176c70f18
10 changed files with 332 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
//
// FESSCheduleEntry.h
// FestivalHelper
//
// Created by Hamo Hapic on 31/08/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import <Foundation/Foundation.h>
@class FESScheduleFilm;
@interface FESSCheduleEntry : NSObject
-(id)initWithJSONData:(NSDictionary*)data;
@property (assign) NSInteger scheduleEntryId;
@property (strong) NSString *scheduleDayOfWeek;
@property (strong) NSString *scheduleDate;
@property (strong) NSString *scheduleYear;
@property (strong) NSMutableArray *scheduleFilms;
@end

View File

@@ -0,0 +1,43 @@
//
// FESSCheduleEntry.m
// FestivalHelper
//
// Created by Hamo Hapic on 31/08/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import "FESSCheduleEntry.h"
#import "FESScheduleFilm.h"
@implementation FESSCheduleEntry
@synthesize scheduleEntryId;
@synthesize scheduleDate;
@synthesize scheduleDayOfWeek;
@synthesize scheduleYear;
@synthesize scheduleFilms;
-(id)initWithJSONData:(NSDictionary*)data{
self = [super init];
if(self){
//NSLog(@"initWithJSONData method called");
self.scheduleEntryId = [[data objectForKey:@"id"] integerValue];
self.scheduleDate = [data objectForKey:@"date"];
self.scheduleDayOfWeek = [data objectForKey:@"dayOfWeek"];
self.scheduleYear = [data objectForKey:@"year"];
self.scheduleFilms = [self extractFilms:[data objectForKey:@"films"]];
}
return self;
}
-(NSMutableArray *)extractFilms:(NSArray *)films {
NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:[films count]];
for (NSDictionary *filmData in films) {
FESScheduleFilm *film = [[FESScheduleFilm alloc] initWithJSONData:filmData];
[result addObject:film];
}
return result;
}
@end

View File

@@ -0,0 +1,21 @@
//
// FESScheduleFilm.h
// FestivalHelper
//
// Created by Hamo Hapic on 31/08/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FESScheduleFilm : NSObject
@property (assign) NSInteger scheduleFilmId;
@property (strong) NSString *scheduleFilmTitle;
@property (strong) NSString *scheduleFilmVenue;
@property (strong) NSString *scheduleFilmTime;
@property (strong) NSString *scheduleFilmDuration;
-(id)initWithJSONData:(NSDictionary*)data;
@end

View File

@@ -0,0 +1,32 @@
//
// FESScheduleFilm.m
// FestivalHelper
//
// Created by Hamo Hapic on 31/08/14.
// Copyright (c) 2014 Senad Uka. All rights reserved.
//
#import "FESScheduleFilm.h"
@implementation FESScheduleFilm
@synthesize scheduleFilmId;
@synthesize scheduleFilmDuration;
@synthesize scheduleFilmTime;
@synthesize scheduleFilmTitle;
@synthesize scheduleFilmVenue;
-(id)initWithJSONData:(NSDictionary*)filmData{
self = [super init];
if(self){
//NSLog(@"initWithJSONData method called");
self.scheduleFilmId = [[filmData objectForKey:@"id"] integerValue];
self.scheduleFilmTitle = [filmData objectForKey:@"title"];
self.scheduleFilmVenue = [filmData objectForKey:@"venue"];
self.scheduleFilmTime = [filmData objectForKey:@"time"];
self.scheduleFilmDuration = [filmData objectForKey:@"duration"];
}
return self;
}
@end