3 ms·
We did look at NSManagedObjectContext... but NSManagedObjectContext doesn't support polymorphism. Yes, it does. For a few reasons: 1) It is passed around as a
by nupark2 15y ago
We did look at NSManagedObjectContext... but NSManagedObjectContext doesn't support polymorphism.
Yes, it does. For a few reasons:
1) It is passed around as an instance, not a global variable, and as such, each instance can be individually configured to behave differently (such as with a different persistence implementation), while still responding to defined API.
2) NSManagedObjectContext can be subclassed.
3) Apple can improve the implementation (and recommend subclassing in the future) without breaking or modifying any existing client code.
You're confusing 'polymorphism' with subclassing. Related, but not the same.
---
Now, I did say that NSManagedObjectContext has many flaws -- and it does, but they're largely unrelated to the use of global variables that we're addressing here.
And, since I'm being downvoted for technical discussion (presumably by you guys or your friends, because I've never seen anything like this to comments like mine on hacker news), I'm going to respond personally:
Your need to find (and listen to) an advisor who has a significant stake in the ObjC space and more experience with API design than you have. You appear to be approaching your API from a Rails-centric perspective, not one rooted in Objective-C application development experience, and certainly not one rooted in the experience of architecting large shipping desktop/mobile applications.
Then again, maybe your target audience are just small throw-away apps, in which case your API is probably fine -- just about any API would be.