Re: Need help with setNeedsDisplay - Another Update
Re: Need help with setNeedsDisplay - Another Update
- Subject: Re: Need help with setNeedsDisplay - Another Update
- From: Yevgeniy Goldberg <email@hidden>
- Date: Sun, 11 Mar 2007 13:49:43 -0500
I did find the third instance and removed it.
This third instance was coming from the second window which I meant
to use at a later time.
This third instance is gone now.
Could you, please, give me a hint as to where the second instance
comes from?
On Mar 11, 2007, at 1:48 PM, Andy Lee wrote:
I suggest you study a bit about what nib files are, how they work,
and possibly what it means to have an instance of a view. It
sounds to me like you are a little confused about these things,
because you weren't sure why there were multiple instances of your
custom view, and yet there they were in plain sight.
I can't tell why three instances of your class were doing
awakeFromNib, but it's clear why at least two were. Keep looking
until you can account for all three.
If I may quote (again) what Erik Buck pointed out:
On Mar 10, 2007, at 5:01 PM, Erik Buck wrote:
The view instance in the window will draw. Any view instance in
the instances pane of the Interface Builder document will not draw
because it isn't contained in any window.
I suspect you have actions connected to the top-level instance of
your custom view -- the one that shows as an icon in the Instances
tab. Those actions will have no effect on the display, because
that instance is not the same instance as the one in your window.
In fact, you should delete the top-level instance because it's
irrelevant to what you're trying to accomplish. You want to
connect your actions to the custom view that's in your window. You
need to understand that those are two *different* instances.
Note: it may help to be in hierarchy mode to make the connections
you want in IB. Sometimes it's easier to draw the connecting line
to the item in the hierarchy view than to the view itself.
--Andy
On Mar 11, 2007, at 2:17 PM, Yevgeniy Goldberg wrote:
The name of my custom view is AdsrView and it does show up twice
in the hierarchical nib view
First, it shows as one of the top level hierarchy items and then
it also shows under the NSWindow->NSView hierarchy as well.
I'm not sending awakeFromNib anywhere in my code. I have only one
nib file. I do not load the nib file explicitly anywhere in my code.
On Mar 11, 2007, at 12:42 PM, Andy Lee wrote:
There's a small, finite number of ways the extra instances could
have gotten there. Bottom line, they're there because you put
them there.
All three instances received the awakeFromNib message, so
presumably they came from a nib file (I assume you're not sending
awakeFromNib in your own code, which would be a mistake). When
you look in the nib file in Interface Builder, do you see three
instances? Try viewing the nib file in hierarchy mode -- in the
Instances tab, there are two small icons above the vertical
scrollbar that let you switch between icon mode and hierarchy
mode. That might reveal the extra instances.
If not, do you have more than one nib file? If not, are you
loading this nib file more than once? Note also what Erik wrote:
On Mar 10, 2007, at 5:01 PM, Erik Buck wrote:
The view instance in the window will draw. Any view instance in
the instances pane of the Interface Builder document will not
draw because it isn't contained in any window.
--Andy
On Mar 11, 2007, at 11:39 AM, Yevgeniy Goldberg wrote:
I did not intend on having 3 instances of my custom view. I
needed just one.
Not sure how to figure out where the other 2 instances come from.
On Mar 11, 2007, at 10:01 AM, Andy Lee wrote:
On Mar 10, 2007, at 9:57 PM, Yevgeniy Goldberg wrote:
I was not deleting the entire custom view, only it's instance
in the nib file.
When this instance is present in the nib file, drawRect will
work, but only after window is resized.
It sounds like you're saying you didn't delete the custom view
*class* from your project (i.e., you were still compiling
the .h and .m files for it). You just deleted the *instance*
that was in the nib file. Well, naturally if your application
never creates an instance of a class, none of the class's
instance methods (such as drawRect:) will ever be called.
Here is the output of one app run:
2007-03-10 20:53:18.456 SoundTemplate05[1299] awoke 0x3982e0
2007-03-10 20:53:18.456 SoundTemplate05[1299] awoke 0x39d380
2007-03-10 20:53:18.456 SoundTemplate05[1299] awoke 0x39cd70
As you have suggested, I've put the NSLog into a blank
awakeFromNib of my custom view class
This output shows that your nib file has three instances of
your custom view. Is this what you intended? I thought you
only had one instance.
I'm not sure how I could use the po command in the debuger
since I do not have this custom view defined as IBOutlet
The purpose of the po suggestion was to look at the object you
were sending the setNeedsDisplay: message to. Since you are
sending it to self, you could say "po self". Or, to see the
memory address of self, you could say "p self".
--Andy
On Mar 10, 2007, at 8:43 PM, Andy Lee wrote:
On Mar 10, 2007, at 5:24 PM, Yevgeniy Goldberg wrote:
Getting rid of an instance of my custom view in the nib file
did not help.
In fact, after I deleted that instance from the nib nothing
was redrawing even after the window resize.
I am confused about the structure of your app. How could
deleting the custom view cause the custom view to correctly
redraw, if it's no longer there?
In any case, I'm sure you/we will get to the bottom of this!
You're *positive* you are calling setNeedsDisplay: where you
think you are? If you put an NSLog before and after it, you
see the log output? (Or you could use a breakpoint as Nick
suggested.)
And are you positive drawRect: is *not* getting called? Can
you confirm this with a breakpoint or NSLog?
And you're positive the instance of the view that you're
sending setNeedsDisplay: to is the right instance? You could
add an awakeFromNib method to the custom view that just does
this:
NSLog(@"awoke 0x%x", self);
And just before you call [self setNeedsDisplay:] you could do
this:
NSLog(@"needs display: 0x%x", self);
And make sure the printed addresses are the same.
As a very blunt, "dumb" test, what if you add a button (or
change the action of an existing one) such that the target is
the custom view and *all* the action does is
setNeedsDisplay:YES? Surely drawRect: should get called
then? (You'll need a breakpoint or NSLog to confirm this,
because no data will have changed.)
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden