Re: Collection of Cocoa & objc questions from a "newbie"
Re: Collection of Cocoa & objc questions from a "newbie"
- Subject: Re: Collection of Cocoa & objc questions from a "newbie"
- From: tyler <email@hidden>
- Date: Mon, 16 Jul 2001 21:35:12 -0700
Thanks to all who responded. I understand several things better (thanks
for the reminders), but there are still things that don't really make
sense to me (I wan't getting compiler warnings and it seemed like I
should).
It's cool that I can override a method without even declaring that that
is what I'm doing. funky.
3) If I set a breakpoint in the (void)dealloc method for the DotView
custom view, it is never called (close window, quit app, never called).
I got several responses to this question and one was:
Then you are not explicitly releasing your dotview object.
Actually, I'm not explicitly creating it so I figured that the loadNib
or whatever that did the creation would take care of disposing of the
view when the window (?) was disposed of. Am I incorrect in this?
The only instance of the DotView object is the one created by whatever
code loads a nib object and then disposes of it when the window is
disposed of.
Another response to this question said:
I see the same thing that you do. I think it's probably a problem with
gdb
but I can't prove it.
Interesting. I wonder how we'd prove it. I tried adding a call to
NSLog to log something out in the dealloc routine, but nothing was
displayed.
Perhaps it would be useful for other more advanced people to take a look
at because it implies the potential for a memory leak (and all kinds of
other problems like not closing connections to things like databases or
whatever if such closing was done in the dealloc method of a view/window
etc).
Does this mean that code in a dealloc method may never be called in
general and shouldn't be counted on getting called?
No, it means you have to explicitly release an object to cause its
dealloc method to be performed.
Even if you didn't explicitly allocate it? I created it as a custom
view in the nib file (as per the example in chapter 8 of Learning Cocoa)
and then set that window to be the first or main window which is created
and displayed automatically. So shouldn't the code that does that
auto-create/display dispose of it when the window is closed?
2) If I set breakpoints in the DotView custom View I see that several
methods are called twice (awakeFromNib and initWithFrame in
particular). It appears the the "self" value in the debugger has
changed so I'm guessing that one call is for the "proxy" object created
due to the nib (not that I really understand what that means, just read
it somewhere), and one is the real object that I defined and that the
proxy instantiates (???).
I'm not seeing this.
Interesting. I wonder what I did differently to get this to happen.
Something in how I interacted with IB I suspect...
Anyway, thanks for the responses.
peace,
tyler