• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need help with setNeedsDisplay - Another Update
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:47:11 -0500

Here is the debugger output:

run
[Switching to process 14443 local thread 0xf03]
Running…
Pending breakpoint 1 - ""AdsrView.m:105" resolved
(gdb) po self
<AdsrView: 0x3c5240>
Current language: auto; currently objective-c
2007-03-11 13:42:32.425 SoundTemplate05[14443] awoke 0x3c5240
2007-03-11 13:42:56.705 SoundTemplate05[14443] awoke 0x3bf030
(gdb) po self
<AdsrView: 0x3bf030>
(gdb)
It certainly looks like awakeFromNib runs twice, producing two different instances of AdsrView
I'll keep searching for the reasons as to why this happens.


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:
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


References: 
 >Re: Need help with setNeedsDisplay - Another Update (From: Erik Buck <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: j o a r <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: Yevgeniy Goldberg <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: Andy Lee <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: Yevgeniy Goldberg <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: Andy Lee <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: Yevgeniy Goldberg <email@hidden>)
 >Re: Need help with setNeedsDisplay - Another Update (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: Need help with setNeedsDisplay - Another Update
  • Next by Date: Re: Need help with setNeedsDisplay - Another Update
  • Previous by thread: Re: Need help with setNeedsDisplay - Another Update
  • Next by thread: Re: Need help with setNeedsDisplay - Another Update
  • Index(es):
    • Date
    • Thread