Professional Web Applications Themes

Controller layer - Mac Programming

Hi, I was wondering if someone could help me get to grips with the controller layer concept, my being new to os x development. I have tried using an NSController class to bind simple text field controls to a model with no problem. I have also followed the example for the NSArrayController to bind a table to a model which worked as advertised. What I don't like about this is that it seems to create an array of my actual model (or that is my perception anyway) rather than pointing to a suitable array within my model. I would ideally ...

  1. #1

    Default Controller layer

    Hi,
    I was wondering if someone could help me get to grips with the controller
    layer concept, my being new to os x development. I have tried using an
    NSController class to bind simple text field controls to a model with no
    problem. I have also followed the example for the NSArrayController to bind
    a table to a model which worked as advertised. What I don't like about this
    is that it seems to create an array of my actual model (or that is my
    perception anyway) rather than pointing to a suitable array within my model.

    I would ideally like is to have some arbitrary model, say a singleton which
    contains data corresponding to a text field and an array corresponding to a
    table (text field and table are unrelated) and then have both an
    NSController and NSArrayController doing their magic between that and the
    view. How would I do this?

    Thanks

    Tommy Guest

  2. #2

    Default Re: Controller layer

    Tommy <com> wrote:
     

    Perhaps I'm just not understanding the question, because I don't
    understand (1) why you want to do this in the second paragraph, since
    you've already done it successfully in the first paragraph, or (2) why,
    if you mean what I think you mean, you don't just read the docs, which
    explain it.

    So please don't be insulted if the answer I give here is the answer to
    the wrong question! I can't believe it's the right question either,
    since the answer is so dead obvious. However, I'll say it anyway.

    I'm assuming you mean you want to establish the binding programmatically
    at runtime. So, for example, let's bind the value of a text field called
    myTextField to an NSString value called theString in the singleton
    instance of a class MySingleton, called theSingleton. Then you'd say
    this:

    [myTextField bind: "value" toObject: theSingleton
    withKeyPath:"theString" options: nil];

    m.

    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  3. #3

    Default Re: Controller layer

    Tommy wrote: 

    You use a key path.

    interface MyModelClass : NSObject
    {
    id myContentsArray;
    }

    then in IB, make an instance of MyModelClass, (say, "myModelInstance")
    and bind your array controller to myModelInstance.myContentsArray.

    -jcr
    John Guest

  4. #4

    Default Re: Controller layer

    In article <BC17A5CB.42D6%com>, Tommy <com>
    wrote:
     

    Other people have already noted that your question is somewhat difficult
    to understand. From my read, it sounds like you want to do a
    -setContent: for the controller(s), possibly in a suitable -awakeFromNib.
    Doc Guest

Similar Threads

  1. Bottom layer spoils its upprt layer
    By jae kim in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 6
    Last Post: August 14th, 01:46 AM
  2. Bottom layer spoils its upper layer
    By jae kim in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 2
    Last Post: August 13th, 06:15 AM
  3. Flash layer on top of normal HTML layer
    By edwardchen webforumsuser@macromedia.com in forum Adobe Flash, Flex & Director
    Replies: 0
    Last Post: August 8th, 03:01 AM
  4. PE2: Selecting and painting a layer having a Hidden Power Tools' layer mask?
    By Richard Hirschman in forum Adobe Photoshop Elements
    Replies: 6
    Last Post: August 7th, 03:05 PM
  5. on Director : 3D layer + flash (SWF) layer (or with other layer type)
    By onelsonic webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 1
    Last Post: July 16th, 01:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139