• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (Newbie) Multiple views in a Core Data app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (Newbie) Multiple views in a Core Data app


  • Subject: Re: (Newbie) Multiple views in a Core Data app
  • From: "I. Savant" <email@hidden>
  • Date: Wed, 2 Aug 2006 14:07:31 -0400

Dennis:

Take a look at the "Sketch" example in your Developer/Examples folder for how to handle the drawing. This is easily adapted to your purpose without relying on a bunch of subviews.

Also, for Core Data, it's really no different. You just need a custom NSManagedObject subclass for your elements (rectangles, in your case). In addition to whatever code you have for the Core Data aspect, you just add a method like:

- (void)drawInView:(id)view withBounds:(NSRect)bounds selected:(BOOL) selected .....

In this way, your objects know how to draw themselves in a view and can get their own properties, etc. easily. During your main editor view's -drawRect: you just cycle through all your Rectangle instances (or only the ones that intersect with the rect being drawn) and tell them to draw themselves in the view.

--
I.S.


On Aug 2, 2006, at 1:06 PM, Dennis Lorson wrote:

Hi,

I'm writing an app which draws rectangles and the likes in a custom view.

Currently, I'm implementing this with Core Data. This means I have a NSManagedObject subclass with a few extra methods for drawing (by means of NSBezierPath) and event handling (based on, and much like the GraphicsBindings example from mmalc's page).
But I run into problems with this approach when doing dragging of these objects. I can't really get the redrawing right, and the hit detection fails when two or more objects overlap.
In short: I want to use a custom NSView for each of these objects, because I think it's better suited for the job.
But how should I encapsulate these in the NSManagedObject subclass objects? By encoding them in an NSData stream?
Or should I just generate the NSViews at runtime for each managed object? This seems more compliant to the MVC ideal, but maybe it would make the design more "complex"...


Hope I made myself clear a bit,


Dennis

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >(Newbie) Multiple views in a Core Data app (From: Dennis Lorson <email@hidden>)

  • Prev by Date: Re: help with intelizing
  • Next by Date: Re: Starting window instead of a new untitled document? [Simple SOLUTION]
  • Previous by thread: (Newbie) Multiple views in a Core Data app
  • Next by thread: help with intelizing
  • Index(es):
    • Date
    • Thread