I’m normally a web developer so I immediately figured a global Cart class would be the way to go since it is semi-analogous to a web session. I also consider Core Data to be for more permanent storage and thus not appropriate for a shopping cart.
However, I am not sure, given the structures and hierarchies that exist within objective-c how to implement a global instance of the cart class. Should I store it in my appdelegate and access it via a method from there much like the managed object context? Or should I just use core data since the MOC is already provided as a global instance via the appdelegate?
Thanks for any advice.
I’d say you’re correct in that a singleton class would be ideal for this scenario, but having to deal with iOS and user actions within the device would lead me to say you should go down the CoreData road.
Consider instances where task switching / closing would cause a cart to be lost and wether or not you’d like the cart to remain after such cases?