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

sending a message from an initializer method


  • Subject: sending a message from an initializer method
  • From: Luc Van Bogaert <email@hidden>
  • Date: Wed, 12 Jan 2011 12:41:48 +0100

Hi,

I have a question about how to design a initializer mehod.

I have defined a class with three instance variables. Two of them are arrays and their value can be initialized straightforward in the initializer method, but the value of the third instance variable is the result of a complex algorithm, based on the contents of the two arrays.

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;
}

Or is it better to write the algorithm directly as part of the initializer?
Thanks,

--
Luc Van Bogaert
email@hidden

_______________________________________________

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: Richard Somers <email@hidden>
    • Re: sending a message from an initializer method
      • From: Frédéric Testuz <email@hidden>
    • Re: sending a message from an initializer method
      • From: Phil Hystad <email@hidden>
  • Prev by Date: Cocoaheads Lake Forest meets Wed, 1/12 at Ozate in Laguna Hills. Note different location!
  • Next by Date: Re: Core Data and Undo. Was: NSUndoManager retain/release
  • Previous by thread: Cocoaheads Lake Forest meets Wed, 1/12 at Ozate in Laguna Hills. Note different location!
  • Next by thread: Re: sending a message from an initializer method
  • Index(es):
    • Date
    • Thread