Core Data + Core Animation/CALayer together??
- by ivanTheTerrible
I am making an Cocoa app with custom interfaces. So far I have implemented one version of the app using CALayer doing the rendering, which has been great given the hierarchical structure of CALayers, and its [hitTest:] function for handling mouse events. In this early version, the model of the app are my custom classes.
However, as the program grows I feel the urge of using Core Data for the model, not just for the ease of binding/undo management, but also want to try out the new technology.
My method so far:
In Core Data: creating a Block entity, with attributes xPos, yPos, width, height...etc.
Then, creating a BlockView : CALayer class for drawing, which uses methods such as self.position.x = [self valueForKey:@"xPos"] to fetch the values from the model.
In this case, every BlockView object has to also keep a local copy of xPos, which is NOT good.
Do any of you guys have better suggestions?
Edit:
This app is a information visualization tool. So the positions, dimensions of the blocks are important, and should be persisted for later analysis.