2

I created a custom operator to change the value only when it's different :

func ?!=<T:Equatable> (inout lhs:T?, rhs:T?) {
    if lhs != rhs {
        lhs = rhs
    }
}

I used it like that :

eventMO.id ?!= eventObject.id

In my NSFetchedResultsControllerDelegate controller(_:didChangeObject:atIndexPath:forChangeType:newIndexPath:) returns NSFetchedResultsChangeType.Move there should be actually nothing when the value is the same.

I tested with the debugger, and the left hand parameter doesn't get modified in my test case.

So I'm guessing : Does an inout operator trigger a change on a NSManagedObject ?

Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134
  • 1
    Managed object properties are computed properties, so this http://stackoverflow.com/questions/31232190/swift-2-0-inout-function-parameters-and-computed-properties would apply here as well, i.e. the setter is called in any case. See also this http://stackoverflow.com/a/34400794/1187415. – Martin R Dec 21 '15 at 17:49
  • Hey Matthieu Riegler, have you solved this issue somehow? – Eugene Zaychenko Dec 15 '18 at 14:38

0 Answers0