I'm learning Objective-C and i have a confusion about self ,so here is the code : the interface :
@interface Person : NSObject
{
float HeightInMeters;
int WeightInKilos;
}
@property float HeightInMeters;
@property int WeightInKilos;
- (float) BodyIndex;
@end
the implementation without self:
@implementation Person
@synthesize HeightInMeters,WeightInKilos;
-(float)BodyIndex
{
float h=HeightInMeters;
float w=WeightInKilos;
return w/(h*h);
}
@end
the implementation using self:
@implementation Person
@synthesize HeightInMeters,WeightInKilos;
-(float)BodyIndex
{
float h=[self HeightInMeters];
float w=[self WeightInKilos];
return w/(h*h);
}
@end
so here is the question : with or without self both code are working fine , so what is the purpose of using self ? thanks