• 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: MVC and NSBezierPath encoding?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MVC and NSBezierPath encoding?


  • Subject: Re: MVC and NSBezierPath encoding?
  • From: Ricky Sharp <email@hidden>
  • Date: Thu, 10 Nov 2005 18:27:08 -0600


On Nov 10, 2005, at 2:25 PM, Andrew Merenbach wrote:

I have a program that displays polygons in a view. The user can rotate these polygons, resize them, change their colours, and change their line widths. I created my polygon class--GMPolygon-- as a subclass of NSBezierPath, and this has been marvellous: I extended the features; added rotation and vertex methods; and added more methods for calculations (angle sum, et cetera). Saving to a file has proven relatively painless, but I am wondering whether I am going about it the right way.

Would a proper coding pattern for this project have only the data for the items encoded, rather than NSBezierPath subclasses?

Not exactly sure what you're asking here. But, NSBezierPath conforms to NSCoding, so your subclass would provide its own implementations of initWithCoder: and encodeWithCoder:. They would of course call through to super, then encode/decode all your custom attributes (size, angle, etc.)


It sounds like your document would then have a collection of these objects (e.g. NSArray or NSDictionary). Since everything in your data object hierarchy conforms to NSCoding, it would be a simple matter of using APIs like unarchiveObjectWithFile: and archiveRootObject:toFile: to read/write all your data.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
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: 
 >MVC and NSBezierPath encoding? (From: Andrew Merenbach <email@hidden>)

  • Prev by Date: Re: Question about NSLocale with NSDateFormatter
  • Next by Date: Re: -[NSURL path] returning empty string for relative file URL
  • Previous by thread: MVC and NSBezierPath encoding?
  • Next by thread: Re: MVC and NSBezierPath encoding?
  • Index(es):
    • Date
    • Thread