Add +nilValueFor<Key> #247

Closed
robb opened this Issue Feb 20, 2014 · 4 comments

Comments

Projects
None yet
2 participants
Owner

robb commented Feb 20, 2014

I was thinking we could add a declarative +nilValueFor<Key> mechanism that -[MTLModel setNilValueForKey:] could fall back to.

E.g.

@interface XYModel : MTLModel

@property (readonly, nonatomic, assign) XYFlavor flavor;

@end

@implementation XYModel

+ (id)nilValueForFlavor {
    return @(XYFlavorVanilla);
}

@end
Owner

jspahrsummers commented Feb 25, 2014

Why would this be better than overriding -setNilValueForKey:? It's usually kind of a hack if that needs to be overridden anyways, since you can avoid nil values via -validate<Key>:error:.

Owner

robb commented Feb 26, 2014

I feel like if it's not usually something people consider (be it through -setNilValueForKey: or -validate<Key>:error:) and I'd like to give it higher visibility.

Owner

jspahrsummers commented Mar 13, 2014

After considering this some more, I think I'd rather figure out some way to surface validation in a more discoverable way than custom nil equivalents.

Owner

robb commented Mar 13, 2014

👍 I'll leave this one open as a reminder til we come up with something.

robb closed this Jul 28, 2015

robb referenced this issue Nov 18, 2015

Closed

fix nil crash #647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment