I have a coredata project and I'm trying to make a query. Here is my coredata model:
NSManagedObjectContext *moc = [self managedObjectContext];
NSEntityDescription *theaterDescription = [ NSEntityDescription entityForName:@"Theaters" inManagedObjectContext:moc];
NSPredicate *theaterPredicate = [NSPredicate predicateWithFormat:@"nameOfTheater like %@ AND nameOfMovie like %@",_theaterName,_movieOutlet.stringValue];
NSFetchRequest *theaterRequestTwo = [NSFetchRequest new];
theaterRequestTwo.entity = theaterDescription;
theaterRequestTwo.predicate = theaterPredicate;
NSError *error = nil;
NSArray *theaterResults = [moc executeFetchRequest:theaterRequestTwo error:&error];
But I'm getting this error:
keypath nameOfMovie not found in entity <NSSQLEntity Theaters id=3>
I also tried :
NSPredicate *theaterPredicate = [NSPredicate predicateWithFormat:@"nameOfTheater like %@ AND Movies.nameOfMovie like %@",_theaterName,_movieOutlet.stringValue];
But I got this error:
keypath Movies.nameOfMovie not found in entity <NSSQLEntity Theaters id=3>
And I also tried:
NSPredicate *theaterPredicate = [NSPredicate predicateWithFormat:@"nameOfTheater like %@ AND movies.nameOfMovie like %@",_theaterName,_movieOutlet.stringValue];
I got the following error:
to-many key not allowed here
By any chance any of you knows what I'm doing wrong or what I'm missing on my code. I'll really appreciate your help.
UPDATE:
This are the headers files for my coredata model:
theaters classe:
@class Movies;
@interface Theaters : NSManagedObject
@property (nonatomic, retain) NSString * nameOfTheater;
@property (nonatomic, retain) NSSet *movies;
@end
@interface Theaters (CoreDataGeneratedAccessors)
- (void)addMoviesObject:(Movies *)value;
- (void)removeMoviesObject:(Movies *)value;
- (void)addMovies:(NSSet *)values;
- (void)removeMovies:(NSSet *)values;
Movies class:
@class Schedules, Theaters;
@interface Movies : NSManagedObject
@property (nonatomic, retain) NSString * nameOfMovie;
@property (nonatomic, retain) NSSet *showTimes;
@property (nonatomic, retain) Theaters *theaters;
@end
@interface Movies (CoreDataGeneratedAccessors)
- (void)addShowTimesObject:(Schedules *)value;
- (void)removeShowTimesObject:(Schedules *)value;
- (void)addShowTimes:(NSSet *)values;
- (void)removeShowTimes:(NSSet *)values;
Schedules class:
@interface Schedules : NSManagedObject
@property (nonatomic, retain) NSDate * showTimes;
@property (nonatomic, retain) NSSet *movie;
@end
@interface Schedules (CoreDataGeneratedAccessors)
- (void)addMovieObject:(Movies *)value;
- (void)removeMovieObject:(Movies *)value;
- (void)addMovie:(NSSet *)values;
- (void)removeMovie:(NSSet *)values;