Professional Web Applications Themes

Cocoa awakeFromNIB: Won't work... - Mac Programming

Hello everyone: Newbie here struggling with initializing an object's properties using the awakeFromNIB method. For me this approach will not work under the simplest of cirstances. After creating a custom sub-class of NSObject, I instantiate it, create an outlet and connect it to a NSTextField. The class header and implementation files are created and the "-(void)awakeFromNIB" method is added to the implementation file. The method's code is simple: set the text of the textField to a whatever e.g [textField setObjectValue:"set by awakeFromNIB"] But, no go. The problem appears that the awakeFromNIB method isn't called. Setting the text from a user ...

  1. #1

    Default Cocoa awakeFromNIB: Won't work...


    Hello everyone: Newbie here struggling with initializing an object's
    properties using the awakeFromNIB method.

    For me this approach will not work under the simplest of cirstances.
    After creating a custom sub-class of NSObject, I instantiate it,
    create an outlet and connect it to a NSTextField. The class header and
    implementation files are created and the "-(void)awakeFromNIB" method
    is added to the implementation file. The method's code is simple: set
    the text of the textField to a whatever e.g [textField
    setObjectValue:"set by awakeFromNIB"]

    But, no go. The problem appears that the awakeFromNIB method isn't
    called. Setting the text from a user action poses no difficulties,
    affirming that the outlet of the instance is connected to the
    NSTextfield.

    What am I doing wrong? Any help would be appreciated.
    Thanks luke
    Luke Guest

  2. #2

    Default Re: Cocoa awakeFromNIB: Won't work...

    Luke <inter.net> wrote:
     

    []
     

    try: - (void)awakeFromNib
    ^^^

    Patrick
    Patrick Guest

  3. #3

    Default Re: Cocoa awakeFromNIB: Won't work...

    Luke <inter.net> wrote:
     

    There is no such method. It is called awakeFromNib. Nib, not NIB. 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

  4. #4

    Default Re: Cocoa awakeFromNIB: Won't work...

    In article <1ghmhe9.f1cfhz1a5lltsN%com>, matt neuburg
    <com> wrote:
     
    >
    > There is no such method. It is called awakeFromNib. Nib, not NIB. m.[/ref]

    Geez. Thanks matt and Paul. I'm beginning to think learning programming
    is an endless lesson in humility.

    luke
    Luke Guest

  5. #5

    Default Re: Cocoa awakeFromNIB: Won't work...

    Luke <inter.net> wrote:
     
    > >
    > > There is no such method. It is called awakeFromNib. Nib, not NIB. m.[/ref]
    >
    > Geez. Thanks matt and Paul. I'm beginning to think learning programming
    > is an endless lesson in humility.[/ref]

    Actually, it's an endless lesson in trying stuff until something works.
    :)

    But make sure you take away the right lesson. (OB1 Kenobee voice:) "Use
    Auto-Completion, Luuuuuke!" Also: "Use Copy and Paste, Luuuuuuke!"
    Basically I *never* type the name of a method myself if I can help it,
    for just this kind of reason. 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

  6. #6

    Default Re: Cocoa awakeFromNIB: Won't work...

    Luke <inter.net> schreef:
     
    >
    > Geez. Thanks matt and Paul.[/ref]
    ^^^^
    There you go again ;-)
     

    It's called debugging... Once you learn to track down and correct your
    own mistakes (and those of others) the rest of programming is easy!

    Patrick <---
    Patrick Guest

  7. #7

    Default Re: Cocoa awakeFromNIB: Won't work...

    In article <280720041225124032%inter.net>,
    Luke <inter.net> wrote:
     
    > >
    > > There is no such method. It is called awakeFromNib. Nib, not NIB. m.[/ref]
    >
    > Geez. Thanks matt and Paul. I'm beginning to think learning programming
    > is an endless lesson in humility.[/ref]

    The most puzzling, inexplicable errors almost always result from the
    simplest of mistakes. :-)

    --
    Tom "Tom" Harrington
    Macaroni, Automated System Maintenance for Mac OS X.
    Version 2.0: Delocalize, Repair Permissions, lots more.
    See http://www.atomicbird.com/
    Tom Guest

  8. #8

    Default Re: Cocoa awakeFromNIB: Won't work...

    Tom Harrington <no.spam.dammit.net> wrote:
     
    > >
    > > Geez. Thanks matt and Paul. I'm beginning to think learning programming
    > > is an endless lesson in humility.[/ref]
    >
    > The most puzzling, inexplicable errors almost always result from the
    > simplest of mistakes. :-)[/ref]

    It's not a matter of the mistake being simple; it's a matter of your
    assumptions being too firm. For me at least, in this sort of situation,
    I find that the reason I made the mistake in the first place is that I
    was convinced, absolutely convinced, beyond any shadow of a doubt, that
    what I was doing was right. Thus, when the time comes to debug, I never
    never never reconsider this assumption, because it's the one thing I'm
    absolutely sure of. I test everything else, but not that. And of course,
    it's the one thing that's wrong. The solution is to let go of every
    assumption, including things you've believed since childhood, things you
    read in the doentation, things the delphic oracle told you, etc. Or
    you can take the shortcut route and ask yourself: "What's the *least*
    likely source of the problem?* and now simply assume, mutatis mutandis,
    that's that's it. You'll usually be right! 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

Similar Threads

  1. Cocoa Newbie
    By BM in forum Mac Programming
    Replies: 13
    Last Post: July 19th, 03:22 PM
  2. Cocoa Quicktime API
    By Eli in forum Mac Programming
    Replies: 2
    Last Post: May 12th, 07:20 PM
  3. C++ in cocoa
    By Robert in forum Mac Programming
    Replies: 6
    Last Post: February 26th, 07:19 PM
  4. Considering Cocoa Books
    By David in forum Mac Programming
    Replies: 10
    Last Post: January 31st, 09:54 PM
  5. initialize between initWithCoder and awakeFromNib
    By matt in forum Mac Programming
    Replies: 3
    Last Post: August 24th, 08:48 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