Property List Serialization in Sketch

  • Sketch uses property list serialization rather than encodeWithCoder,
    encodeObject:forKey:, etc.  Is there any particular advantage/disadvantage
    to this?  Don't they ultimately do the same thing?  If it is to set up all
    the KVOs, couldn't the same thing be done either way?

        I should mention that I use only one type of graphic object class for
    everything, differentiated only by the content of a properties dictionary.
    (In fact, now that I've done it, I don't know why I didn't just make that
    class a subclass of NSMutableDictionary.)
  • We need someone else who knows more about these things than me to
    chime in, but...

    On 2008 Jan, 09, at 19:52, Gordon Apple wrote:

    > Sketch uses property list serialization rather than encodeWithCoder,
    > encodeObject:forKey:, etc.  Is there any particular advantage/
    > disadvantage
    > to this?  Don't they ultimately do the same thing?  If it is to set
    > up all
    > the KVOs, couldn't the same thing be done either way?

    I thought that the Sketch example code was depracated several years
    ago and replaced with Sketch-112.  But I see that it is still in
    Leopard's /Developer/Examples/AppKit/.  Maybe someone who knows can
    please set us straight on which is the latest "Sketch" we should be
    using??

    > I should mention that I use only one type of graphic object class for
    > everything, differentiated only by the content of a properties
    > dictionary.
    > (In fact, now that I've done it, I don't know why I didn't just make
    > that
    > class a subclass of NSMutableDictionary.)

    I can't find the reference now, but I seem to remember that
    subclassing Cocoa's Collection classing is highly discouraged and
    leads to trouble.  So, the reason why you didn't subclass
    NSMutableDictionary is that you apparently have excellent intuition.
  • Le 10 janv. 08 à 04:52, Gordon Apple a écrit :

    > Sketch uses property list serialization rather than
    > encodeWithCoder,
    > encodeObject:forKey:, etc.  Is there any particular advantage/
    > disadvantage
    > to this?  Don't they ultimately do the same thing?  If it is to set
    > up all
    > the KVOs, couldn't the same thing be done either way?
    >
    > I should mention that I use only one type of graphic object class
    > for
    > everything, differentiated only by the content of a properties
    > dictionary.
    > (In fact, now that I've done it, I don't know why I didn't just make
    > that
    > class a subclass of NSMutableDictionary.)

    encodeWithCoder: is for archiving, NSPropertyList is for serialization:
    The two solution are valid and do not do the same thing. The
    difference is discussed here:

    http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Concept
    s/objectgraphs.html
  • I've been through that document twice and it still doesn't explain why
    you would want one or the other.  I finally tossed Sketch's property lists
    and just went with archiving for cut/copy/paste/drag/drop, since I already
    had that for file storage.  It works, and it was a lot simpler.

        What I was really trying to get at is whether or not the property list
    approach was preferred for attempts at commonality between applications.

        I really wish there was some standard list for keyed graphic properties
    that would promote commonality across applications, instead of everyone
    rolling their own.

    > Le 10 janv. 08 à 04:52, Gordon Apple a écrit :
    >
    >> Sketch uses property list serialization rather than
    >> encodeWithCoder,
    >> encodeObject:forKey:, etc.  Is there any particular advantage/
    >> disadvantage
    >> to this?  Don't they ultimately do the same thing?  If it is to set
    >> up all
    >> the KVOs, couldn't the same thing be done either way?
    >>
    >> I should mention that I use only one type of graphic object class
    >> for
    >> everything, differentiated only by the content of a properties
    >> dictionary.
    >> (In fact, now that I've done it, I don't know why I didn't just make
    >> that
    >> class a subclass of NSMutableDictionary.)
    >
    > encodeWithCoder: is for archiving, NSPropertyList is for serialization:
    > The two solution are valid and do not do the same thing. The
    > difference is discussed here:
    >
    > http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Concept
    s/o

    > bjectgraphs.html
    >
  • The 10.5 Sketch has apparently been greatly upgraded, and is eyeball
    deep in bindings and KVOs, so much so that it requires substantial study and
    really needs an extensive tutorial.  I guarantee that you'll be well versed
    in both if you get through it and understand it.  Our architecture is
    radically different, but we've still been able to lift/modify a substantial
    amount of code from it.

        Some of the differences are there is a single "Shape" class with a
    dictionary of properties.  Shapes don¹t draw -- there is a separate
    rendering class that is very straightforward, handles drawing, selection
    handles, hit detection, etc., with a simple API and no external object
    references (except to handle the shadow scaling fiasco).  The main view
    subclass has one method -- it overrides "draw" to call the display
    controller.  There is a display controller and an edit controller, the later
    being an NSResponder subclass inserted as the view's "nextResponder".  This
    partitioning (and a variety of single-purpose controllers) allows multiple
    reuse in different nibs with different purposes.  (I guess it's my systems
    engineering background coming through here.  :-)

        Regarding collection classes, I did an extensive subclass of
    NSMutableArray --  although on hindsight, most of it could have been (and
    may still be) done as a category.

    > We need someone else who knows more about these things than me to
    > chime in, but...
    >
    > On 2008 Jan, 09, at 19:52, Gordon Apple wrote:
    >
    >> Sketch uses property list serialization rather than encodeWithCoder,
    >> encodeObject:forKey:, etc.  Is there any particular advantage/
    >> disadvantage
    >> to this?  Don't they ultimately do the same thing?  If it is to set
    >> up all
    >> the KVOs, couldn't the same thing be done either way?
    >
    > I thought that the Sketch example code was depracated several years
    > ago and replaced with Sketch-112.  But I see that it is still in
    > Leopard's /Developer/Examples/AppKit/.  Maybe someone who knows can
    > please set us straight on which is the latest "Sketch" we should be
    > using??
    >
    >> I should mention that I use only one type of graphic object class for
    >> everything, differentiated only by the content of a properties
    >> dictionary.
    >> (In fact, now that I've done it, I don't know why I didn't just make
    >> that
    >> class a subclass of NSMutableDictionary.)
    >
    > I can't find the reference now, but I seem to remember that
    > subclassing Cocoa's Collection classing is highly discouraged and
    > leads to trouble.  So, the reason why you didn't subclass
    > NSMutableDictionary is that you apparently have excellent intuition.
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today