How to separate model and view with Core Data?

Posted by andrewebling on Stack Overflow See other posts from Stack Overflow or by andrewebling
Published on 2010-05-27T15:19:07Z Indexed on 2010/05/27 15:21 UTC
Read the original article Hit count: 188

Filed under:
|
|
|
|

I have a subclass of UIView which draws itself based on data held in a corresponding model class, which is a subclass of NSManagedObject.

The problem is, some fields in the data model (e.g. the position of the view) are already held in the view (i.e. the frame property in this case). I then have a data duplication/synchronization problem to solve.

To complicate matters further, the view needs to update in response to changes made to the data model and the data model needs to be updated in responses made to the view (e.g. the user dragging it to a new location).

What's the best way to solve this? Using KVO and references in both directions?

Or is there a better approach?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mvc