• 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: sending a message from an initializer method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sending a message from an initializer method


  • Subject: Re: sending a message from an initializer method
  • From: Richard Somers <email@hidden>
  • Date: Thu, 13 Jan 2011 17:29:58 -0700

On Jan 12, 2011, at 4:41 AM, Luc Van Bogaert wrote:

I would like to implement that algorithm in a seperate method, instead of writing it directly in the initializer. Is that OK, and could I then message "self" in the initializer like:

- (id) init
{
	self = [super init];
	if (self) {
		var1 = ...;
		var2 = ...;
		var3 = [self computerVar3With:var1:var2];
	}
	return self;
}


I often will do something like this.

- (id)init
{
     self = [super init];
     if (self) {
         [self prepare...];
         [self prepare...];
         [self prepare...];
         // etc...
     }
     return self;
}

The methods 'prepare...' are all private methods. The preparation code for one of my classes is over 300 lines with five individual prepare methods. Breaking it up like this keeps it organized, understandable, and aids in debugging and refactoring. It works very well.

--Richard Somers

_______________________________________________

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: sending a message from an initializer method
      • From: Andreas Grosam <email@hidden>
References: 
 >sending a message from an initializer method (From: Luc Van Bogaert <email@hidden>)

  • Prev by Date: Maintaining NSCursor outside of app window
  • Next by Date: Re: Maintaining NSCursor outside of app window
  • Previous by thread: Re: sending a message from an initializer method
  • Next by thread: Re: sending a message from an initializer method
  • Index(es):
    • Date
    • Thread