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: Thu, 08 Sep 2016 22:35:18 +1000
> On 8 Sep 2016, at 9:27 PM, Raimond Hettrich <email@hidden> wrote:
>
> @interface DelegateClass : NSView <DocumentProtocol> {
> NSMutableArray *delegateArray;
>
>
> __weak IBOutlet Document *documentOutlet;
> }
>
> @end
>
>
> //
> // DelegateClass.m
> // Test
> //
>
> #import "DelegateClass.h"
>
> @implementation DelegateClass
>
> - (void)drawRect:(NSRect)dirtyRect {
> [super drawRect:dirtyRect];
>
>
> [self showArray];
> }
>
> - (id)init {
> self = [super init];
> if (self) {
> delegateArray = [[NSMutableArray alloc]init];
> }
> return self;
> }
>
The -init method of DelegateClass will never run. It’s not the designated initializer for a NSView (-initWithFrame: is, but it could also be -initWithCoder: depending on the setting in the nib), so your array will never be created. That’s probably why it’s nil in -drawRect.
I don’t really understand what your ‘document protocol’ is doing, but I also notice that you craete a different array in the Document class. Wouldn’t you just want an array in one place, not two different ones?
—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