Search code examples
swiftcore-datansmutablearraynsmanagedobject

Swift NSManagedObjects do not support mutableSetValueForKey


I am practicing my tute task on Swift CoreData. This is a reminder app, I have these entities in the core data file:

And the error is in my viewDidLoad() function:

var reminderList: NSMutableArray

//In viewDidLoad() {
    super.viewDidLoad()

    //fetchRequest code blocks

    self.reminderList = NSMutableArray(array: (currentReminders?.members?.allObjects) as! [Reminder])

I got this error message: 'NSManagedObjects of entity 'ReminderList' do not support -mutableSetValueForKey: for the property 'members'' and the app crashed.


Solution

  • This problem is because of a mistake in setting relationship between entities in the CoreData. Just check to see if the constraints are set properly for To-One/Many.