Re: What difference exist from where a method will be called?
Re: What difference exist from where a method will be called?
- Subject: Re: What difference exist from where a method will be called?
- From: Graham Cox <email@hidden>
- Date: Fri, 09 Sep 2016 00:01:52 +1000
> On 8 Sep 2016, at 11:13 PM, Raimond Hettrich <email@hidden> wrote:
>
> the init-method of the DelegateClass is running. This is because I have a class object in the Document.xib file
Alarm bells. What exactly does this mean?
I assume you mean you have a custom view within the document’s window, and you’ve set its class to ‘DelegateClass’. That is the normal way to add NSView subclasses in a xib. Depending on the ‘Prefer Coder’ checkbox for the xib, the -initWithFrame: or -initWithCoder: methods will be called. I don’t see that -init will ever be called. The only way to be sure is to set a debugger breakpoint in the -init method.
If you’ve added an object to the xib and set its class to ‘DelegateClass’ as well as having a view in the window, you’ll have two of them. One is on screen and is reporting from its -drawRect method, the other is the one that’s responding to the button and showing its array. If that’s the case, its -init method WILL be called, because it’s being treated as a plain object, not an NSView.
From what you’ve described, this would fit the logging output you’re seeing, but because you haven’t logged the identity of the view itself, you haven’t seen that there are two. A breakpoint would reveal that, because you can see the address of the object.
—Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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