title: Designated initializer in Objective-C
body: <p>Just to confirm is that the correct way to create designated initializer in Objective-C ?</p>
  
  <p>Is this the correct way to init the ivars ?</p>
  
  <p>Can you suggest me what to improve ?</p>
  
  <p>Person.h</p>
  
  <pre><code>@interface Person : NSObject 
  
  
  @property (nonatomic, retain) NSString *name;
  @property (nonatomic, assign) int age;
  @property (nonatomic, assign) NSString *sex;
  @property (nonatomic, assign) int weight;
  
  -(id)initWithName:(NSString *)name;
  -(id)initWithName:(NSString *)name age:(int)age;
  -(id)initWithName:(NSString *)name age:(int)age sex:(NSString *)s;
  -(id)initWithName:(NSString *)name age:(int)age sex:(NSString *)s andWeight:(float)w;
  
  
  @end
  </code></pre>
  
  <p>Person.m</p>
  
  <pre><code>@implementation Person
  
  @synthesize name = _name;
  @synthesize sex = _sex;
  @synthesize age = _age;
  @synthesize weight = _weight;
  
  -(id)initWithName:(NSString *)name age:(int)age sex:(NSString *)s andWeight:(float)w
  {
      if(self = [super init])
      {
          [self setName:name];
          [self setAge:age];
          [self setSex:s];
          [self setWeight:w];
      }
      return self;
  }
  
  -(id)initWithName:(NSString *)name age:(int)age sex:(NSString *)s
  {
      return [self initWithName:name age:age sex:s andWeight:0];
  }
  
  -(id)initWithName:(NSString *)name age:(int)age
  {
      return [self initWithName:name age:age sex:0];
  }
  
  -(id)initWithName:(NSString *)name
  {
      return [self initWithName:name age:0];
  }
  
  -(id)init
  {
      return [self initWithName:nil];
  }
  </code></pre>
  
  <p>Thanks in advance !</p>