I am currently developing an app that relies heavily on retrieving web content. I have a series of NSObject classes that represent the content that I retrieve in JSON format. I also have NSManagedObject classes that represent my Core Data model that are almost identical.
Here is an example of an NSObject class that I use to hold my web content:
@interface MovieRecord : NSObject {
NSString *movieTitle;
NSDecimalNumber *movieId;
NSString *movieRating;
NSString *movieDescription;
NSDate *movieReleaseDate;
NSMutableArray *movieVideos; // collection of class videoRecord
NSMutableArray *actors;
UIImage *movieImage;
NSURL *movieImageURL;
}
And here is an example of my NSManagedObject class:
@interface Movie : NSManagedObject
{
}
@property (nonatomic, retain) NSNumber * id;
@property (nonatomic, retain) NSString * description;
@property (nonatomic, retain) id image;
@property (nonatomic, retain) NSString * rating;
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSDate * releaseDate;
@property (nonatomic, retain) NSString * imageURL;
@property (nonatomic, retain) NSSet* actors;
@end
In this example a user will look through a lot of movies but they will not always be saving the movie to the persistent store. That was my main reason for storing the information into seperate classes first, then if they decide to save it, I will populate the NSManaged object classes and save. The NSObject class will not be fully populated until a user has drilled down to the detail view (initially only movieTitle and movieID will be set).
I guess my question here is does it makes sense to keep these classes separate? Is there a better design approach to this that I am just not seeing? Should I just stick to using the NSDictionary to populate my table views (NSDictionary is populated from the JSON data)?