• 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: What difference exist from where a method will be called?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: What difference exist from where a method will be called?
      • From: Raimond Hettrich <email@hidden>
References: 
 >What difference exist from where a method will be called? (From: Raimond Hettrich <email@hidden>)
 >Re: What difference exist from where a method will be called? (From: Jens Alfke <email@hidden>)
 >Re: What difference exist from where a method will be called? (From: Raimond Hettrich <email@hidden>)

  • Prev by Date: Re: What difference exist from where a method will be called?
  • Next by Date: Re: Window Opened Notification?
  • Previous by thread: Re: What difference exist from where a method will be called?
  • Next by thread: Re: What difference exist from where a method will be called?
  • Index(es):
    • Date
    • Thread