NSArrayController question

  • I'm reading Hillegass book and in chapter 6 he introduces a project called
    RaiseMan. It is a document-based application. In MyDocument.nib he creates
    an instance of NSArrayController. With Inspector he opens the attributes
    tab, sets the "Object Class Name" to Person and adds two keys called
    personName and expectedRaise. (Person is a class that we have created
    earlier which contains the two instance variables personName and
    expectedRaise). He then creates a two column table, and using KVC he binds
    the columns to NSArrayController and to personName and expectedRaise.

    Now we come to chapter 7 and he wants to introduce undo capabilities to the
    application. Instead of having NSArrayController keep its own array of
    Person objects, he stores the array inside MyDocument, and sets the
    NSArrayController's contentArray binding to use MyDocument's array as its
    content. He does that by  going to bindings inspector for the
    NSArrayController. He expands the settings for the contentArray binding and
    chooses File's Owner (MyDocument) from the Bind to: pop-up menu. He then
    enter employees for the Model Key Path. (MyDocument has two instance
    variables: employee which is a pointer to an NSMutableArray object and
    personController which is a pointer to a NSArrayController object).

    But Hillegass does not make any changes to the the attributes inspector for
    the NSArrayController. The object Class Name is still Person and the keys
    are still personName and expectedRaise. So what does this mean? Does our
    NSArrayController have two arrays to keep track of. The first one that is
    defined in attributes inspector for the NSArrayController, and the second
    one defined in the NSArrayController's contentArray binding?

    Thanks Frank
  • On Sep 23, 2007, at 5:50 AM, Frank Bettger wrote:

    > Does our NSArrayController have two arrays to keep track of.
    >
    No. <http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
    cepts/CntrlContent.html
    >.

    mmalc
  • Thanks for the link, but it's no help to me. Apple's reference docs have
    Cocoa-savvy people as their target audience, not newbies like me. I've tried
    to read the one you pointed at, but it was the same frustration as with some
    other refdocs I tried before. They are simply not aimed at newbies like me.
    So where should a newbie get some help. I'm hoping at the forum like this.
    Sure there are books and tutorials but they can't answer a specific question
    that a newbie has. Traditionally a newbie could always turn to a forum and
    get some relevant help, because there always seem to be some helpful souls.
    I know that some Cocoa-savvy people get irritated at newbies because they
    can't formulate their questions succinctly enough or because they ask
    questions that from the experts point of view is only noise and bandwidth
    waste. But I think that a forum like this should allow the full spectrum,
    from novices to experts, to participate.

    Frank

    On 9/23/07, mmalc crawford <mmalc_lists...> wrote:
    >
    >
    > On Sep 23, 2007, at 5:50 AM, Frank Bettger wrote:
    >
    >> Does our NSArrayController have two arrays to keep track of.
    >>
    > No. <
    > http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/Con
    cepts/CntrlContent.html

    >> .
    >
    > mmalc
    >
    >
  • On Sep 23, 2007, at 10:10 AM, Frank Bettger wrote:

    > Thanks for the link, but it's no help to me. Apple's reference docs
    > have
    > Cocoa-savvy people as their target audience, not newbies like me.
    >

    As has been said so many times on this forum -- most recently by Chris
    Hanson at <http://lists.apple.com/archives/Cocoa-dev/2007/Sep/msg00956.html> -- technologies such as bindings and Core Data are not for
    "newbies".  If you don't have sufficient experience and understanding
    of fundamental Cocoa design patterns to use them, then if you get
    frustrated you have no-one but yourself to blame.  The documentation
    is *not* going to make itself less useful to those who have followed
    an appropriate and recommended path to learning by trying to cater to
    those who have not.

    If, on the other hand, you have requisite experience and find the
    documentation inadequate or confusing, then by all means file a bug.
    And when you post a question here, make it clear that you have read
    the documentation and say what you found confusing -- which leads to:

    > I know that some Cocoa-savvy people get irritated at newbies because
    > they
    > can't formulate their questions succinctly enough or because they ask
    > questions that from the experts point of view is only noise and
    > bandwidth
    > waste.
    >
    No, this is not the case.  All list members are less likely to be
    helpful when any others post messages that don't adhere to the
    guidelines <> or <<A href="http://www.mikeash.com/getting_answers.html">http://www.mikeash.com/getting_answers.html>.

    > But I think that a forum like this should allow the full spectrum,
    > from novices to experts, to participate.
    >
    It does, and it's offensive to those who give freely and generously of
    their time to help others to suggest otherwise.

    mmalc
  • >
    > The first one that is
    > defined in attributes inspector for the NSArrayController, and the second
    > one defined in the NSArrayController's contentArray binding?
    >

    there is no "first one that is defined in attributes inspector".  you're
    telling the array controller what kind of objects are being controlled.  in
    the bindings (contentArray), you tell it which specific array to control.
    it's like me telling you "you will drive A honda accord" and then telling
    you "you will drive THIS car".
    maybe you are confused about NSArrayController... it is not an array.  it
    can control one however, and in his example, he is: the array in
    MyDocument.

    NSArrayControllers do a lot of lifting for you, you don't have to implement
    key methods for KVO or KVC, it handles this for you.  KVO and KVC are
    extremely useful, so anything that helps me utilize that with very little
    code is awesome.

    Apple's reference docs have Cocoa-savvy people as their target audience

    do they?  i've never seen "cocoa-savvy people" listed under "Who Should Read
    This Document" which is at the beginning of just about every reference doc.

    some of the docs are advanced yes, but so is driving on the highway for
    someone who just got their learners permit.  that's why they usually don't
    start learning on the highway, they start in open fields or large parking
    lots.  if you don't understand a document, try reading one of it's
    prerequisites.  follow that chain until you do understand.  i've found
    myself reading docs to understand a doc which will explain a doc that
    details something i really want to learn.  it sucks sometimes, reading 5
    things to get to the one i really want, but it builds a strong base of
    understanding.  i'm better in the long run.

    the cocoa bindings programming guide (linked above) suggest you read *Key-Value
    Coding Programming
    Guide<http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/in
    dex.html#//apple_ref/doc/uid/10000107i
    >
    *, *Key-Value Observing Programming
    Guide<http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving
    /index.html#//apple_ref/doc/uid/10000177i
    >
    **Value Transformer Programming
    Guide<http://developer.apple.com/documentation/Cocoa/Conceptual/ValueTransformers
    /index.html#//apple_ref/doc/uid/10000175i
    >
    * before you try to read the bindings guide.  after reading them i'm sure it
    will make more sense.

    Traditionally a newbie could always turn to a forum and get some relevant
    > help, because there always seem to be some helpful souls

    there are more helpful people on the forum than i can count, and i can count
    to like 100.  mmalc specifically is very helpful, although if you read the
    threads you'll find him repeating himself often.  always search
    http://www.cocoabuilder.com for you question before posting to the list,
    odds are your question has been asked before.

    Cocoa-savvy people get irritated at newbies

    this is not cocoa specific :)

    hope some of this helps

    +Clint

    On 9/23/07, Frank Bettger <frankbettger...> wrote:
    >
    > Thanks for the link, but it's no help to me. Apple's reference docs have
    > Cocoa-savvy people as their target audience, not newbies like me. I've
    > tried
    > to read the one you pointed at, but it was the same frustration as with
    > some
    > other refdocs I tried before. They are simply not aimed at newbies like
    > me.
    > So where should a newbie get some help. I'm hoping at the forum like this.
    > Sure there are books and tutorials but they can't answer a specific
    > question
    > that a newbie has. Traditionally a newbie could always turn to a forum and
    > get some relevant help, because there always seem to be some helpful
    > souls.
    > I know that some Cocoa-savvy people get irritated at newbies because they
    > can't formulate their questions succinctly enough or because they ask
    > questions that from the experts point of view is only noise and bandwidth
    > waste. But I think that a forum like this should allow the full spectrum,
    > from novices to experts, to participate.
    >
    > Frank
    >
    >
    >
    > On 9/23/07, mmalc crawford <mmalc_lists...> wrote:
    >>
    >>
    >> On Sep 23, 2007, at 5:50 AM, Frank Bettger wrote:
    >>
    >>> Does our NSArrayController have two arrays to keep track of.
    >>>
    >> No. <
    >> http://developer.apple.com/documentation/Cocoa/Conceptua
    > l/CocoaBindings/Concepts/CntrlContent.html
    >>> .
    >>
    >> mmalc
    >>
    >>

    >
  • On 23 Sep 2007, at 18:10, Frank Bettger wrote:

    > Thanks for the link, but it's no help to me.

    Well it would have been if you'd taken it as a starting point in
    looking for what you were after... if you look on the Introduction
    page for the document mmalc pointed you at, you'll find a link to this:

      http://developer.apple.com/documentation/Cocoa/Conceptual/
    CurrencyConverterBindings/

    which should make the answer to your original question fairly
    obvious.  If you work through that example, and (maybe) compare it
    with the original currency converter sample (which doesn't use
    bindings), I think you'll find it easier to understand.

    > Apple's reference docs have Cocoa-savvy people as their target
    > audience,
    > not newbies like me. I've tried to read the one you pointed at, but
    > it was
    > the same frustration as with some other refdocs I tried before.

    Apple's Guide documentation (which is what you were pointed at) is
    actually quite good, but it does have to assume some prerequisites
    otherwise it'll be restating the basics all the time, which will get
    in the way of what it's trying to explain.  The Introduction pages
    usually state what the author of the document expects you to have
    read (and understood), so you can tell when you're getting in over
    your head, and also where you need to look to avoid that problem.

    (Perhaps someone should draw a chart of all of the documents and
    their pre-requisites so that people who want to study a particular
    topic can see what they need to learn first...)

    > They are simply not aimed at newbies like me.

    Some of them are, some of them aren't, and there are different types
    and levels of newbie.  It's possible (for instance) to be an expert
    on vanilla Cocoa, but to be a newbie at bindings or Core Data.  I'm
    in the latter camp myself... I haven't really used Core Data at all
    to date, because of the kinds of apps I work on.  So there, I'm a
    newbie (and that's why you won't generally find me answering
    questions about Core Data...).

    > So where should a newbie get some help. I'm hoping at the forum
    > like this.

    Yes, *but* the people here won't lead you by the nose to your
    answer.  Nobody has time to do that for all of the people who might
    post questions to the list, so sometimes you'll get a fairly terse
    answer if you ask a question that (a) is something you could have
    found for yourself, (b) is obvious, (c) is the same question that ten
    other people just asked, (d) doesn't make sense, etc. etc.

    So even though the answer was terse, remember that mmalc (who is a
    volunteer) did give you an answer and also tried to point you to
    somewhere where you could find more information.

    Kind regards,

    Alastair.

    --
    http://alastairs-place.net
previous month september 2007 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
Go to today