> On 8 Sep 2016, at 9:27 PM, Raimond Hettrich <sa...@onlinehome.de> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to