Re: Convenience initialisers

2009-07-05 Thread Andy Lee
On Jul 5, 2009, at 1:40 PM, DKJ wrote: I'm trying to write one of those convenient class initialisers for one of my objects. On my still-incomplete understanding of these matters, this is what I need to have: Header: + (MyObject *)myObject; Implementation: + (MyObject *)myObject {

Re: Convenience initialisers

2009-07-05 Thread Dimitri Bouniol
My mistake haha. I guess you learn something new everyday. On Jul 5, 2009, at 10:55 AM, Chris Hanson wrote: You absolutely can (and should!) send +alloc to self in a class method like this. In a class method, "self" represents the class, not an instance of the class. This is one reason it

Re: Convenience initialisers

2009-07-05 Thread Ken Thomases
On Jul 5, 2009, at 12:40 PM, DKJ wrote: I'm trying to write one of those convenient class initialisers for one of my objects. On my still-incomplete understanding of these matters, this is what I need to have: Header: + (MyObject *)myObject; Implementation: + (MyObject *)myObject {

Re: Convenience initialisers

2009-07-05 Thread Chris Hanson
You absolutely can (and should!) send +alloc to self in a class method like this. In a class method, "self" represents the class, not an instance of the class. This is one reason it's important not to refer to class methods as "static methods," as less dynamic languages do. In Objective-C,

Re: Convenience initialisers

2009-07-05 Thread Dimitri Bouniol
You can't tell 'self' to be allocated. Try this instead: + (MyObject *)myObject { return [[[MyObject alloc] init] autorelease]; } On Jul 5, 2009, at 10:40 AM, DKJ wrote: I'm trying to write one of those convenient class initialisers for one of my objects. On my still-incomplete un