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;
> }
>
>
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
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
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.
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,
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
>
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
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]
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
alg