Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using Core Data generated accessors

So I've got two entities, one called "List" and one called "Task". Each of them has multiple attributes and one relationship. The relationship for List is called "hasTasks" and it is a one to many relationship.

This is the Task.h file that is generated for me.

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

@class Task;

@interface List : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSNumber * number;
@property (nonatomic, retain) NSNumber * tasks;
@property (nonatomic, retain) NSNumber * totalTime;
@property (nonatomic, retain) NSSet *hasTasks;
@end

@interface List (CoreDataGeneratedAccessors)

- (void)addHasTasksObject:(Task *)value;
- (void)removeHasTasksObject:(Task *)value;
- (void)addHasTasks:(NSSet *)values;
- (void)removeHasTasks:(NSSet *)values;

@end

Now whenever I call something along the lines of

[self.list addHasTasksObject:task];

my app crashes when it gets to this point. Anybody have an idea why this is? If you need to see any more of my code, don't hesitate to ask. Thanks in advance!

like image 881
user2539621 Avatar asked Apr 17 '26 01:04

user2539621


1 Answers

I had this same problem and I fixed it in the .xcdatamodeld file. I had accidentally selected the ordered arrangement checkbox for a relationship without re-generating the NSManagedObject classes. Unchecking this box and re-building solved this problem for me. If you are still having a problem, try re-generating your NSManagedObject classes.

like image 84
brad.roush Avatar answered Apr 20 '26 21:04

brad.roush



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!