Re: sending a message from an initializer method

2011-01-14 Thread Andreas Grosam
On Jan 14, 2011, at 1:29 AM, Richard Somers wrote: > I often will do something like this. > > - (id)init > { > self = [super init]; > if (self) { > [self prepare...]; > [self prepare...]; > [self prepare...]; > // etc... > } > return self; > } > >

Re: sending a message from an initializer method

2011-01-13 Thread Richard Somers
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 (s

Re: sending a message from an initializer method

2011-01-13 Thread Erik Buck
Fair enough. On Jan 13, 2011, at 1:19 PM, Uli Kusterer wrote: > On Jan 13, 2011, at 1:27 AM, Erik Buck wrote: >> Class or instance method makes no difference in this case with regard to >> polymorphism. > > It does. He's only passing the two instance variables to the class method. > And, being

Re: sending a message from an initializer method

2011-01-13 Thread Uli Kusterer
On Jan 13, 2011, at 1:27 AM, Erik Buck wrote: > Class or instance method makes no difference in this case with regard to > polymorphism. It does. He's only passing the two instance variables to the class method. And, being a class method, "self" is the class, not the half-initialized instance.

Re: sending a message from an initializer method

2011-01-12 Thread Erik Buck
Class or instance method makes no difference in this case with regard to polymorphism. On Jan 12, 2011, at 4:51 PM, Gordon Apple wrote: > What I would do use a class method and pass the two arrays as parameters. > > > On 1/12/11 2:03 PM, "cocoa-dev-requ...@lists.apple.com" > wrote: > >> Yes,

Re: sending a message from an initializer method

2011-01-12 Thread Gordon Apple
What I would do use a class method and pass the two arrays as parameters. On 1/12/11 2:03 PM, "cocoa-dev-requ...@lists.apple.com" wrote: > Yes, you can, but... don't forget that in -computeVar3... self is not fully > initialized. If you have all control on self it can be without problems, but >

Re: sending a message from an initializer method

2011-01-12 Thread Frédéric Testuz
Yes, you can, but... don't forget that in -computeVar3... self is not fully initialized. If you have all control on self it can be without problems, but Objective-C is an OO language. Consider this : - Your class is ClassA with it's init method. - Then you have ClassB, subclass of ClassA. Class

Re: sending a message from an initializer method

2011-01-12 Thread Phil Hystad
You can do the following, in your implementation file create a local procedure and then call it from your init method. I did not bother copying your arguments but you define them in the regular way. -(void)myCalculation { // do the calculation } - (id) init { if ( self = [super init]