Professional Web Applications Themes

Instantiation - Mac Programming

Here's a general question. When should I instantiate, and when should I not? Is an instantiated object necessarily a controller? Should I even *have* that many instatiations in a nib? In fact, as it stands, if an object isn't instantiated, I don't know how to use it. With instantiation, you create methods/outlets and hook 'em up to interface objects -- easy. With non-instantiation, I can create outlets and methods, but I don't know what to do to make other objects act on them. Thanks. -- "love is the search beneath one's spamguy **at** foxchange(.)com tiny expectations"...

  1. #1

    Default Instantiation

    Here's a general question. When should I instantiate, and when should I not?
    Is an instantiated object necessarily a controller? Should I even *have*
    that many instatiations in a nib?

    In fact, as it stands, if an object isn't instantiated, I don't know how to
    use it. With instantiation, you create methods/outlets and hook 'em up to
    interface objects -- easy. With non-instantiation, I can create outlets and
    methods, but I don't know what to do to make other objects act on them.

    Thanks.

    --
    "love is
    the search beneath one's spamguy **at** foxchange(.)com
    tiny expectations"

    Will Oram Guest

  2. #2

    Default Re: Instantiation

    In <BB41D317.AE89%spamguyihate.spammers.com> Will Oram wrote:
    > Here's a general question. When should I instantiate, and when should
    > I not? Is an instantiated object necessarily a controller? Should I
    > even *have* that many instatiations in a nib?
    Here's how to think of it. You never *have* to instantiate in a nib; in
    fact, you never *have* to use a nib. Everything the nib does, you can do
    in code. You could make a window from scratch, put subviews into it, and
    hook up references and targets. However, if there is only one of
    something in a nib and it's easier to let the nib do the instantiation
    for you, and you don't mind the memory overhead of having this thing
    exist as long as the nib is open, then go right ahead.
    > In fact, as it stands, if an object isn't instantiated, I don't know
    > how to use it. With instantiation, you create methods/outlets and hook
    > 'em up to interface objects -- easy. With non-instantiation, I can
    > create outlets and methods, but I don't know what to do to make other
    > objects act on them.
    Well, that's what the file's owner is for. That is NOT an object
    instantiated in the nib; it's just a proxy for something instantiated
    elsewhere (typically the NSApplication or an NSWindowController). You
    can make connections between that and anything else in the nib, so as
    long as you can get a reference to that instance in code, you have the
    desired communication.

    But there are many, many other ways for objects to relate besides
    through connections drawn in the nib. A view has superviews and subviews.
    A view has a window. A thing may have a delegate, a target, a formatter.
    These are all relationship that can be set in code and, just as
    important, may be fetched in code. Finally, remember that you often
    don't need a direct connection in order to send a message; you can use a
    nil-targeted action or a notification. m.

    --
    matt neuburg, phd = [email]matttidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
    REALbasic: The Definitive Guide! 2nd edition!
    [url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
    Subscribe to TidBITS. It's free and smart.
    matt neuburg Guest

Similar Threads

  1. Dynamic Object Instantiation
    By Chip in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: September 15th, 02:01 AM
  2. WebService class instantiation
    By gumnam in forum Macromedia Flex General Discussion
    Replies: 6
    Last Post: July 20th, 10:53 PM
  3. com instantiation
    By CFhound in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: July 6th, 04:15 PM
  4. Class Instantiation in PHP5
    By Paul Laughlin in forum PHP Development
    Replies: 1
    Last Post: August 26th, 08:02 PM
  5. COM instantiation hangs in web method
    By Amyn in forum ASP.NET Web Services
    Replies: 2
    Last Post: June 3rd, 04:16 AM

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