开发者

How can I create a graphics drawing of a Core Data entity?

I'm trying to create a graphic representation of a core data entity. I have a custom view (subclass of NSView) where the drawing will happen. My entity has name, width, and height attributes. When I click the "add" button to add a new model object, I also want to create a simple rectangle for each model object created drawn within the custom view. I have my table views set up for the data, and they are working great.

Do I place an array controller, and an object instance in the custom view 开发者_开发知识库nib file, and somehow use bindings?


Generally you do this by implementing the drawRect: function in your custom NSView. You should somehow inform your NSView of entity changes - both in the properties of your entities, as well as when they are added or deleted - and have your view redraw itself when these changes occur.

Inside the drawRect: function, you can iterate over your entities, getting the height and width attributes and using the Cocoa Drawing functions to translate those entities into visible rectangles within your view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜