Question

I have a many to many relationship in CoreData.

Teams has team info and is linked to Schedule which has meet info. A team can have many conferences and a meet has multiple teams attending.

CoreData generated NSManagedObject Sub-classes like this:

//
//  ScheduleDetails.h

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

@class SchoolRecords;

@interface ScheduleDetails : NSManagedObject

@property (nonatomic, retain) NSString * meetCity;
@property (nonatomic, retain) NSSet *whatTeams;
@end

@interface ScheduleDetails (CoreDataGeneratedAccessors)

- (void)addWhatTeamsObject:(SchoolRecords *)value;
- (void)removeWhatTeamsObject:(SchoolRecords *)value;
- (void)addWhatTeams:(NSSet *)values;
- (void)removeWhatTeams:(NSSet *)values;

@end

I create an instance of SchoolRecords* in category class of SchoolRecords and try to call:

[ScheduleDetail addWhatTeamsObject:thisSchool]. 

But get the compile error:

No known class method for selector 'addWhatTeamsObject:'

I am importing ScheduleDetails.h

Apple's instructions say I am supposed to add an @dynamic addWhatTeamsObject (I presume), but I cannot figure out where to implement that.

When I try to implement the @dynamic attribute, I simply get two compile errors.

I also tried implementing addWhatTeamsObject in a TableViewController where a method returns an instance of a SchoolRecords*. I get the same error.

I can add more detail if that would be helpful. I have looked around for an example of how these relationships can be established but am coming up blank.

Thanks for your help.

Was it helpful?

Solution

[ScheduleDetail addWhatTeamsObject:thisSchool];

should be

[thisSchedule addWhatTeamsObject:thisSchool];

where

ScheduleDetails *thisSchedule;

is the instance that you want add a team to.

(All necessary @dynamic declarations should already be in the Xcode generated managed object subclass files. There is probably no reason that you have to add your own.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top