Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude properties from being considered regarding equality #57

Closed
amyworrall opened this issue Jan 8, 2013 · 5 comments
Closed

Exclude properties from being considered regarding equality #57

amyworrall opened this issue Jan 8, 2013 · 5 comments

Comments

@amyworrall
Copy link

Suppose I have some properties that hold cached data — stuff that can be derived but at a time penalty, so I'm cacheing it in the model. I'd like to exclude such properties from equality calculations. Perhaps there should be a method +(NSSet*)keypathsToExcludeFromEquality that you can override to easily exclude them?

I love that object equality is handled for me by default. It'd be even better if it was customisable in this manner!

@dannygreg
Copy link

I like that idea quite a bit.

I would suggest hacking and sending a pull request, code is always better than a suggestion 😄

@amyworrall
Copy link
Author

I'm playing with this and a few other additions in a project I'm working on. I'll see how well they stand up to use, and if they work OK I'll look into contributing.

@dannygreg
Copy link

Exactly the reason a pull request is always preferred. :neckbeard:

I'm going to close this in the anticipation of a future pull request. Would love to see what you come up with!

@foo4u
Copy link

foo4u commented Jan 8, 2013

I know this just got closed, but if a pull request is going to be created, I suggest the method be made inverse. Perhaps MTLModel can provide (NSSet *)propertyKeysForEquality that subclasses can override to remove elements that aren't desired for equality testing.

@jspahrsummers
Copy link
Member

I think this should be handled with an application-level override of -isEqual:, since we could go on forever about all the different ways that people would like to override MTLModel's default behaviors. Subclassing and overriding works quite well, and generally reduces the complexity of the MTLModel interface.

Suppose I have some properties that hold cached data — stuff that can be derived but at a time penalty, so I'm cacheing it in the model. I'd like to exclude such properties from equality calculations.

In this particular case, it sounds like you would want to exclude those properties from most things, including copying and archiving. That can be done with a +propertyKeys override.

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

No branches or pull requests

4 participants