Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Avoid setting values when equal #18

Merged
merged 3 commits into from
Mar 11, 2015

Conversation

samkaufman
Copy link
Contributor

In some cases, it’s useful to avoid calling setters when the values are known to be equal. In particular, calling a setter on an NSManagedObject will flag that object as updated in the context, which will trigger a database write, even if [newValue isEqual:oldValue].

This adds an optional -mts_checkValueOfKeyForEqualityBeforeAssignment:.

@vilanovi
Copy link
Contributor

vilanovi commented Mar 2, 2015

Hello @samkaufman, thanks for the pull request. I like the idea of what you are doing. I'll check the code and merge the pull request later today (and release a new cocoa pod version).

Cheers,

@samkaufman
Copy link
Contributor Author

@vilanovi Hope it helps!

vilanovi added a commit that referenced this pull request Mar 11, 2015
Avoid setting values when equal
@vilanovi vilanovi merged commit ee4c896 into mobilejazz:master Mar 11, 2015
@vilanovi
Copy link
Contributor

Hello @samkaufman ,

Just published to cocoa pods the new version of Motis 1.1.0 with your changes.

I have, however, updated the name of your method to "mts_checkValueEqualityBeforeAssignmentForKey".

Also, checkout the new feature of value mapping very useful for enums:
https://github.com/mobilejazz/Motis#12-value-mapping

Thanks,

@samkaufman
Copy link
Contributor Author

Fantastic. Thanks, @vilanovi.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants