-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Idetas Movie Share
- Loading branch information
Showing
53 changed files
with
806 additions
and
109 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// SCDirectorViewController.h | ||
// scanorama | ||
// | ||
// Created by Lion User on 01/10/2012. | ||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "Movies.h" | ||
|
||
@interface SCDirectorViewController : UIViewController | ||
|
||
@property (strong, nonatomic) Movies *movieData; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// SCDirectorViewController.m | ||
// scanorama | ||
// | ||
// Created by Lion User on 01/10/2012. | ||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "SCDirectorViewController.h" | ||
|
||
@interface SCDirectorViewController () | ||
|
||
@end | ||
|
||
@implementation SCDirectorViewController | ||
@synthesize movieData = _movieData; | ||
|
||
|
||
-(void) viewWillAppear:(BOOL)animated { | ||
NSLog(@"%@", _movieData.director); | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
} | ||
|
||
- (void)viewDidUnload | ||
{ | ||
[super viewDidUnload]; | ||
// Release any retained subviews of the main view. | ||
} | ||
|
||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | ||
{ | ||
return (interfaceOrientation == UIInterfaceOrientationPortrait); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// SCJsonDatabase.h | ||
// scanorama | ||
// | ||
// Created by Lion User on 20/09/2012. | ||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "Movies.h" | ||
#import "Schedule.h" | ||
|
||
@interface SCJsonDatabase : NSObject <NSFetchedResultsControllerDelegate> | ||
|
||
|
||
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController; | ||
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; | ||
|
||
- (void) insertMoviesJsonToDatabase; | ||
-(void) insertScheduleJsonToDatabase; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// | ||
// SCJsonDatabase.m | ||
// scanorama | ||
// | ||
// Created by Lion User on 20/09/2012. | ||
// Copyright (c) 2012 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "SCJsonDatabase.h" | ||
#import "SCAppDelegate.h" | ||
|
||
@implementation SCJsonDatabase | ||
|
||
|
||
@synthesize managedObjectContext = _managedObjectContext; | ||
@synthesize fetchedResultsController = _fetchedResultsController; | ||
|
||
- (id)init | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
|
||
SCAppDelegate *app = [UIApplication sharedApplication].delegate; | ||
_managedObjectContext = app.managedObjectContext; | ||
} | ||
return self; | ||
} | ||
|
||
|
||
|
||
-(void) insertScheduleJsonToDatabase { | ||
|
||
NSManagedObjectContext *context = _managedObjectContext; | ||
NSError *error; | ||
|
||
NSString* dataPath = [[NSBundle mainBundle] pathForResource:@"schedule" ofType:@"json"]; | ||
NSArray* ScheduleArray = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:dataPath] | ||
options:kNilOptions | ||
error:&error]; | ||
NSLog(@"%i", [ScheduleArray count]); | ||
|
||
[ScheduleArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | ||
NSError *err; | ||
NSDateFormatter *df = [[NSDateFormatter alloc] init]; | ||
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; | ||
|
||
|
||
Schedule *scheduleDb = [NSEntityDescription insertNewObjectForEntityForName:@"Schedule" inManagedObjectContext:context]; | ||
|
||
|
||
// NSLog(@"%@", [obj objectForKey:@"movie"]); | ||
NSFetchRequest *fetchMovieRequest = [[NSFetchRequest alloc] init]; | ||
NSEntityDescription *entityMovie = [NSEntityDescription | ||
entityForName:@"Movies" inManagedObjectContext:context]; | ||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"movieId=%@", [obj objectForKey:@"movie"]]; | ||
[fetchMovieRequest setPredicate:predicate]; | ||
[fetchMovieRequest setEntity:entityMovie]; | ||
|
||
NSArray *fetchedMovie = [context executeFetchRequest:fetchMovieRequest error:&err]; | ||
|
||
if([fetchedMovie count]){ | ||
Movies *movieQuery = [fetchedMovie objectAtIndex:0]; | ||
scheduleDb.date = [df dateFromString:[obj objectForKey:@"date"]]; | ||
scheduleDb.city = [obj objectForKey:@"city"]; | ||
scheduleDb.cinema = [obj objectForKey:@"cinema"]; | ||
scheduleDb.favorite = 0; | ||
scheduleDb.movie = movieQuery; | ||
/* | ||
NSMutableSet *scheduleSet = [NSMutableSet setWithSet:moviesInsert.schedule]; | ||
[scheduleSet addObject:scheduleDb]; | ||
moviesInsert.schedule = (NSSet *) [scheduleSet copy]; | ||
*/ | ||
|
||
// NSLog(@"%@",scheduleDb.movie); | ||
} | ||
|
||
// Movies *movieDB = [fetchedMovie objectAtIndex:0]; | ||
|
||
// NSLog(@"%@", movieDB); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// NSLog(@"%@", scheduleDb); | ||
// failedBankInfo.word = [obj objectForKey:@"word"]; | ||
// failedBankInfo.translations = [obj objectForKey:@"trans"]; | ||
|
||
NSError *error; | ||
if (![context save:&error]) { | ||
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]); | ||
} | ||
|
||
|
||
|
||
}]; | ||
// NSLog(@"%@,", ScheduleArray); | ||
|
||
} | ||
|
||
|
||
- (void) insertMoviesJsonToDatabase{ | ||
|
||
NSManagedObjectContext *context = _managedObjectContext; | ||
|
||
NSError* err = nil; | ||
NSString* dataPath = [[NSBundle mainBundle] pathForResource:@"movies" ofType:@"json"]; | ||
NSArray* MoviesArray = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:dataPath] | ||
options:kNilOptions | ||
error:&err]; | ||
|
||
[MoviesArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { | ||
Movies *moviesDB = [NSEntityDescription insertNewObjectForEntityForName:@"Movies" inManagedObjectContext:context]; | ||
|
||
moviesDB.movieId = [obj objectForKey:@"movieId"]; | ||
moviesDB.title = [obj objectForKey:@"title"]; | ||
moviesDB.titleEn = [obj objectForKey:@"titleEn"]; | ||
moviesDB.titleNative = [obj objectForKey:@"titleNative"]; | ||
moviesDB.createdYear = [obj objectForKey:@"createdYear"]; | ||
moviesDB.director = [obj objectForKey:@"director"]; | ||
moviesDB.duration = [obj objectForKey:@"duration"]; | ||
moviesDB.fullImage = [obj objectForKey:@"fullImage"]; | ||
moviesDB.thumbImage = [obj objectForKey:@"thumbImage"]; | ||
moviesDB.country = [obj objectForKey:@"country"]; | ||
moviesDB.screenplay = [obj objectForKey:@"screenplay"]; | ||
moviesDB.cinematography = [obj objectForKey:@"cinematography"]; | ||
moviesDB.editing = [obj objectForKey:@"editing"]; | ||
moviesDB.music = [obj objectForKey:@"music"]; | ||
moviesDB.group = [obj objectForKey:@"group"]; | ||
moviesDB.cast = [obj objectForKey:@"cast"]; | ||
moviesDB.moviedescription = [obj objectForKey:@"moviedescription"]; | ||
moviesDB.directorDescription = [obj objectForKey:@"directorDescription"]; | ||
moviesDB.directorFilms = [obj objectForKey:@"directorFilms"]; | ||
moviesDB.videoUrl = @"http://www.youtube.com/embed/oHg5SJYRHA0"; | ||
|
||
|
||
|
||
NSLog(@"%i", 1); | ||
// failedBankInfo.word = [obj objectForKey:@"word"]; | ||
// failedBankInfo.translations = [obj objectForKey:@"trans"]; | ||
|
||
NSError *error; | ||
if (![context save:&error]) { | ||
NSLog(@"Whoops, couldn't save: %@", [error localizedDescription]); | ||
} | ||
|
||
|
||
}]; | ||
|
||
|
||
} | ||
|
||
@end |
Oops, something went wrong.