• 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: Simplifying this code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simplifying this code?


  • Subject: Re: Simplifying this code?
  • From: Mario Diana <email@hidden>
  • Date: Mon, 26 Jul 2004 20:39:04 -0400

On Monday, July 26, 2004, at 07:08 PM, Theodore H. Smith wrote:

Heres an interesting problem. How to simplify this kind of code.

I have a window, with lots of controls on it, textfields, switch buttons, color panels, etc.

The state of this window, which is defined by the state of the controls on the window, can be saved as a string, and loaded in from a string.

[...]

Is there a better way??

Couldn't you model all of the state with a class, and then implement the NSCoding protocol for that class?

Maybe I'm reading too much into this, and pardon me if I am, but it seems like your design is a non-object-oriented way of doing things. I wouldn't save the state of something as complex as a window with lots of controls on it to a string. Wrap it all up in an object. Cocoa provides a nice implementation for serializing ("archiving") objects, and a collection object (like NSArray) implements this already.

Use the tools the framework provides, and venture not into the land of unadulterated C. ;-)

(My 2 cents!)

Mario

=======================================================
Mario Diana Mobile: 845-380-8428
50 Forest Drive Home: 845-221-3989
Poughquag, NY 12570 Email: email@hidden
=======================================================
Programmer - Web development, Java, XML, LAMP, Mac OS X
=======================================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Simplifying this code?
      • From: Hasan Diwan <email@hidden>
References: 
 >Simplifying this code? (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Default button background black for dual G5, not single G4
  • Next by Date: Re: awakeFromNib being called twice?
  • Previous by thread: Simplifying this code?
  • Next by thread: Re: Simplifying this code?
  • Index(es):
    • Date
    • Thread