Skip to content

Commit

Permalink
data model update
Browse files Browse the repository at this point in the history
  • Loading branch information
artemkalinovsky committed Sep 25, 2014
1 parent a946f55 commit 5b955d0
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 182 deletions.
227 changes: 80 additions & 147 deletions .idea/workspace.xml

Large diffs are not rendered by default.

30 changes: 18 additions & 12 deletions Cinemania.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

/* Begin PBXBuildFile section */
B2D29F4073EC6DD9F2AC625D /* MoviesDataController.m in Sources */ = {isa = PBXBuildFile; fileRef = B2D291316C2978983B5484DE /* MoviesDataController.m */; };
C80FD30B19D4669700B04FBA /* Actor.m in Sources */ = {isa = PBXBuildFile; fileRef = C80FD30A19D4669700B04FBA /* Actor.m */; };
C80FD30E19D46A5F00B04FBA /* Film.m in Sources */ = {isa = PBXBuildFile; fileRef = C80FD30D19D46A5F00B04FBA /* Film.m */; };
C80FD31119D46A6000B04FBA /* Movie.m in Sources */ = {isa = PBXBuildFile; fileRef = C80FD31019D46A6000B04FBA /* Movie.m */; };
C81A20F019CC49EE00BE951E /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = C81A20DE19CC49EE00BE951E /* AFHTTPRequestOperation.m */; };
C81A20F119CC49EE00BE951E /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C81A20E019CC49EE00BE951E /* AFHTTPRequestOperationManager.m */; };
C81A20F219CC49EE00BE951E /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C81A20E219CC49EE00BE951E /* AFHTTPSessionManager.m */; };
Expand All @@ -29,8 +32,6 @@
C81B4D6419CC7F95003B99C7 /* ILMovieDBConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = C81B4D6019CC7F95003B99C7 /* ILMovieDBConstants.m */; };
C876EFFD19C6FE4A005F0225 /* TVShow.m in Sources */ = {isa = PBXBuildFile; fileRef = C876EFFC19C6FE4A005F0225 /* TVShow.m */; };
C876F00619C71292005F0225 /* MovieTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C876F00519C71292005F0225 /* MovieTableViewCell.m */; };
C8885D6F19D0669F007F49B1 /* Movie.m in Sources */ = {isa = PBXBuildFile; fileRef = C8885D6E19D0669F007F49B1 /* Movie.m */; };
C8885D7219D066A0007F49B1 /* Film.m in Sources */ = {isa = PBXBuildFile; fileRef = C8885D7119D066A0007F49B1 /* Film.m */; };
C8C8342E19C3210500563D95 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8C8342D19C3210500563D95 /* Foundation.framework */; };
C8C8343019C3210500563D95 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8C8342F19C3210500563D95 /* CoreGraphics.framework */; };
C8C8343219C3210500563D95 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8C8343119C3210500563D95 /* UIKit.framework */; };
Expand Down Expand Up @@ -64,6 +65,12 @@
/* Begin PBXFileReference section */
B2D290B78E9A674FDA05B06A /* MoviesDataController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoviesDataController.h; sourceTree = "<group>"; };
B2D291316C2978983B5484DE /* MoviesDataController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoviesDataController.m; sourceTree = "<group>"; };
C80FD30919D4669700B04FBA /* Actor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Actor.h; sourceTree = "<group>"; };
C80FD30A19D4669700B04FBA /* Actor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Actor.m; sourceTree = "<group>"; };
C80FD30C19D46A5F00B04FBA /* Film.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Film.h; sourceTree = "<group>"; };
C80FD30D19D46A5F00B04FBA /* Film.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Film.m; sourceTree = "<group>"; };
C80FD30F19D46A6000B04FBA /* Movie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Movie.h; sourceTree = "<group>"; };
C80FD31019D46A6000B04FBA /* Movie.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Movie.m; sourceTree = "<group>"; };
C81A20DA19CC3AAE00BE951E /* rsz_metroui-apps-windows-moviemaker-icon-2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "rsz_metroui-apps-windows-moviemaker-icon-2x.png"; sourceTree = "<group>"; };
C81A20DD19CC49EE00BE951E /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
C81A20DE19CC49EE00BE951E /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -110,10 +117,6 @@
C876EFFC19C6FE4A005F0225 /* TVShow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TVShow.m; sourceTree = "<group>"; };
C876F00419C71292005F0225 /* MovieTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MovieTableViewCell.h; sourceTree = "<group>"; };
C876F00519C71292005F0225 /* MovieTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MovieTableViewCell.m; sourceTree = "<group>"; };
C8885D6D19D0669F007F49B1 /* Movie.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Movie.h; sourceTree = "<group>"; };
C8885D6E19D0669F007F49B1 /* Movie.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Movie.m; sourceTree = "<group>"; };
C8885D7019D066A0007F49B1 /* Film.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Film.h; sourceTree = "<group>"; };
C8885D7119D066A0007F49B1 /* Film.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Film.m; sourceTree = "<group>"; };
C8C8342A19C3210500563D95 /* Cinemania.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Cinemania.app; sourceTree = BUILT_PRODUCTS_DIR; };
C8C8342D19C3210500563D95 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
C8C8342F19C3210500563D95 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -258,10 +261,12 @@
C876EFF619C6FCF5005F0225 /* Entities */ = {
isa = PBXGroup;
children = (
C8885D7019D066A0007F49B1 /* Film.h */,
C8885D7119D066A0007F49B1 /* Film.m */,
C8885D6D19D0669F007F49B1 /* Movie.h */,
C8885D6E19D0669F007F49B1 /* Movie.m */,
C80FD30C19D46A5F00B04FBA /* Film.h */,
C80FD30D19D46A5F00B04FBA /* Film.m */,
C80FD30F19D46A6000B04FBA /* Movie.h */,
C80FD31019D46A6000B04FBA /* Movie.m */,
C80FD30919D4669700B04FBA /* Actor.h */,
C80FD30A19D4669700B04FBA /* Actor.m */,
C876EFFB19C6FE4A005F0225 /* TVShow.h */,
C876EFFC19C6FE4A005F0225 /* TVShow.m */,
);
Expand Down Expand Up @@ -458,9 +463,8 @@
buildActionMask = 2147483647;
files = (
C81B4D6319CC7F95003B99C7 /* ILMovieDBClient.m in Sources */,
C8885D7219D066A0007F49B1 /* Film.m in Sources */,
C80FD30E19D46A5F00B04FBA /* Film.m in Sources */,
C81A20F519CC49EE00BE951E /* AFURLConnectionOperation.m in Sources */,
C8885D6F19D0669F007F49B1 /* Movie.m in Sources */,
C8C8344019C3210500563D95 /* CinemaniaAppDelegate.m in Sources */,
C81A20F419CC49EE00BE951E /* AFSecurityPolicy.m in Sources */,
C8C8344C19C3210500563D95 /* CinemaniaDetailViewController.m in Sources */,
Expand All @@ -470,6 +474,7 @@
C8C8344919C3210500563D95 /* CinemaniaMasterViewController.m in Sources */,
C8C8343C19C3210500563D95 /* main.m in Sources */,
C876EFFD19C6FE4A005F0225 /* TVShow.m in Sources */,
C80FD31119D46A6000B04FBA /* Movie.m in Sources */,
C81A212E19CC4B1100BE951E /* UIImageView+AFNetworking.m in Sources */,
C81A212F19CC4B1100BE951E /* UIProgressView+AFNetworking.m in Sources */,
C81A20F819CC49EE00BE951E /* AFURLSessionManager.m in Sources */,
Expand All @@ -478,6 +483,7 @@
C81A20F719CC49EE00BE951E /* AFURLResponseSerialization.m in Sources */,
C81A212D19CC4B1100BE951E /* UIButton+AFNetworking.m in Sources */,
C81A212B19CC4B1100BE951E /* UIActivityIndicatorView+AFNetworking.m in Sources */,
C80FD30B19D4669700B04FBA /* Actor.m in Sources */,
C876F00619C71292005F0225 /* MovieTableViewCell.m in Sources */,
C81A20F619CC49EE00BE951E /* AFURLRequestSerialization.m in Sources */,
C81A20F319CC49EE00BE951E /* AFNetworkReachabilityManager.m in Sources */,
Expand Down
14 changes: 11 additions & 3 deletions Cinemania/Cinemania.xcdatamodeld/Cinemania.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="6244" systemVersion="13F34" minimumToolsVersion="Automatic" macOSVersion="Automatic" iOSVersion="Automatic">
<entity name="Actor" representedClassName="Actor" syncable="YES">
<attribute name="actorID" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="firstName" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="lastName" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="movie" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Movie" inverseName="actors" inverseEntity="Movie" syncable="YES"/>
</entity>
<entity name="Film" representedClassName="Film" isAbstract="YES" syncable="YES">
<attribute name="filmID" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="originalTitle" attributeType="String" syncable="YES"/>
Expand All @@ -9,13 +16,14 @@
</entity>
<entity name="Movie" representedClassName="Movie" parentEntity="Film" syncable="YES">
<attribute name="budget" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="casts" attributeType="Binary" syncable="YES"/>
<attribute name="overview" attributeType="String" syncable="YES"/>
<attribute name="revenue" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="runtime" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<relationship name="actors" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Actor" inverseName="movie" inverseEntity="Actor" syncable="YES"/>
</entity>
<elements>
<element name="Film" positionX="-27" positionY="18" width="128" height="118"/>
<element name="Movie" positionX="-27" positionY="189" width="128" height="118"/>
<element name="Film" positionX="-207" positionY="-262" width="128" height="118"/>
<element name="Movie" positionX="-209" positionY="-72" width="128" height="103"/>
<element name="Actor" positionX="79" positionY="35" width="128" height="118"/>
</elements>
</model>
7 changes: 3 additions & 4 deletions Cinemania/CinemaniaMasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)awakeFromNib
- (void)viewDidLoad
{
[super viewDidLoad];
[ILMovieDBClient sharedClient].apiKey = @"ed2f89aa774281fcada8f17b73c8fa05";
/*[ILMovieDBClient sharedClient].apiKey = @"ed2f89aa774281fcada8f17b73c8fa05";
[[ILMovieDBClient sharedClient] GET:kILMovieDBMoviePopular parameters:nil block:^(id responseObject, NSError *error)
{
if (!error) {
Expand All @@ -52,11 +52,10 @@ - (void)viewDidLoad
}
}
}];
/*
}];*/

self.movieDataController = [[MoviesDataController alloc] init];
[self.movieDataController fetchPopularMoviesWithParams:nil andManagedObjectContext:self.managedObjectContext];
*/
NSMutableArray* newPaths = [NSMutableArray array];
for (int i = 0; i < 20; i++)
{
Expand Down
22 changes: 22 additions & 0 deletions Cinemania/Model/Entities/Actor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Actor.h
// Cinemania
//
// Created by Artem Kalinovsky on 9/25/14.
// Copyright (c) 2014 com.softserve. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Movie;

@interface Actor : NSManagedObject

@property (nonatomic, retain) NSNumber * actorID;
@property (nonatomic, retain) NSString * firstName;
@property (nonatomic, retain) NSString * lastName;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) Movie *movie;

@end
22 changes: 22 additions & 0 deletions Cinemania/Model/Entities/Actor.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Actor.m
// Cinemania
//
// Created by Artem Kalinovsky on 9/25/14.
// Copyright (c) 2014 com.softserve. All rights reserved.
//

#import "Actor.h"
#import "Movie.h"


@implementation Actor

@dynamic actorID;
@dynamic firstName;
@dynamic lastName;
@dynamic name;
@dynamic movie;


@end
5 changes: 3 additions & 2 deletions Cinemania/Model/Entities/Film.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Film.h
// Cinemania
//
// Created by Artem Kalinovsky on 9/22/14.
// Created by Artem Kalinovsky on 9/25/14.
// Copyright (c) 2014 com.softserve. All rights reserved.
//

Expand All @@ -18,7 +18,8 @@
@property (nonatomic, retain) NSDate * releaseDate;
@property (nonatomic, retain) NSNumber * voteAverage;


-(instancetype) initWithServerResponse:(NSDictionary*)responseObject andManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;
-(NSString *)getFormatedReleaseDate:(NSDate *)releaseDate;
-(instancetype)initWithServerResponse:(NSDictionary*)responseObject andManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;

@end
12 changes: 6 additions & 6 deletions Cinemania/Model/Entities/Film.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Film.m
// Cinemania
//
// Created by Artem Kalinovsky on 9/22/14.
// Created by Artem Kalinovsky on 9/25/14.
// Copyright (c) 2014 com.softserve. All rights reserved.
//

Expand All @@ -23,11 +23,11 @@ -(instancetype) initWithServerResponse:(NSDictionary*)responseObject andManagedO
self = [NSEntityDescription insertNewObjectForEntityForName:@"Film" inManagedObjectContext:managedObjectContext];
if (self)
{
[self setValue:responseObject[@"id"] forKey:@"filmID"];
[self setValue:responseObject[@"poster_path"] forKey:@"posterPath"];
[self setValue:responseObject[@"original_title"] forKey:@"originalTitle"];
//[self setValue:[responseObject objectForKey:@"release_date"] forKey:@"releaseDate"];
[self setValue:responseObject[@"vote_average"] forKey:@"voteAverage"];
/*[self setValue:responseObject[@"id"] forKey:@"filmID"];
[self setValue:responseObject[@"poster_path"] forKey:@"posterPath"];
[self setValue:responseObject[@"original_title"] forKey:@"originalTitle"];
[self setValue:[responseObject objectForKey:@"release_date"] forKey:@"releaseDate"];
[self setValue:responseObject[@"vote_average"] forKey:@"voteAverage"];*/
return self;
}
return nil;
Expand Down
13 changes: 10 additions & 3 deletions Cinemania/Model/Entities/Movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@
// Movie.h
// Cinemania
//
// Created by Artem Kalinovsky on 9/22/14.
// Created by Artem Kalinovsky on 9/25/14.
// Copyright (c) 2014 com.softserve. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "Film.h"

@class Actor;

@interface Movie : Film

@property (nonatomic, retain) NSNumber * budget;
@property (nonatomic, retain) NSData * casts;
@property (nonatomic, retain) NSString * overview;
@property (nonatomic, retain) NSNumber * revenue;
@property (nonatomic, retain) NSNumber * runtime;
@property (nonatomic, retain) NSSet *actors;
@end

@interface Movie (CoreDataGeneratedAccessors)

-(instancetype)initWithServerResponse:(NSDictionary*)responseObject andManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;
- (void)addActorsObject:(Actor *)value;
- (void)removeActorsObject:(Actor *)value;
- (void)addActors:(NSSet *)values;
- (void)removeActors:(NSSet *)values;

@end
26 changes: 21 additions & 5 deletions Cinemania/Model/Entities/Movie.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,48 @@
// Movie.m
// Cinemania
//
// Created by Artem Kalinovsky on 9/22/14.
// Created by Artem Kalinovsky on 9/25/14.
// Copyright (c) 2014 com.softserve. All rights reserved.
//

#import "Movie.h"
#import "Actor.h"


@implementation Movie

@dynamic budget;
@dynamic casts;
@dynamic overview;
@dynamic revenue;
@dynamic runtime;

@dynamic actors;

-(instancetype) initWithServerResponse:(NSDictionary*)responseObject andManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
{
self = [super initWithServerResponse:responseObject andManagedObjectContext:managedObjectContext];
// self = [super initWithServerResponse:responseObject andManagedObjectContext:managedObjectContext];
self = [NSEntityDescription insertNewObjectForEntityForName:@"Movie" inManagedObjectContext:managedObjectContext];
if (self)
{
[self setValue:responseObject[@"id"] forKey:@"filmID"];
[self setValue:responseObject[@"poster_path"] forKey:@"posterPath"];
[self setValue:responseObject[@"original_title"] forKey:@"originalTitle"];
[self setValue:responseObject[@"vote_average"] forKey:@"voteAverage"];
//add runtime,casts, overview
[self setValue:@"" forKey:@"overview"];
// [self setValue:nil forKey:@"casts"];
[self setValue:@(0) forKey:@"revenue"];
[self setValue:@(0) forKey:@"budget"];
[self setValue:@(0) forKey:@"runtime"];

NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
//2013-10-04
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSDate* releaseDate = [dateFormatter dateFromString:responseObject[@"release_date"]];
[self setValue:releaseDate forKey:@"releaseDate"];

return self;
}
return nil;
}


@end

0 comments on commit 5b955d0

Please sign in to comment.