Is function overloading possible in Objective C ?
Well,Most of the programmers says no,
But it looks like possible,
for example:
-(int)AddMethod:(int)X :(int)Y
{
return X + Y;
}
-(int)AddMethod:(int)X
{
return X;
}
to call 1st one write [self AddMethod :3];
to call last one write [self AddMethod: 3 :4];
Method overloading is not possible in Objective-C. However, your example actually will work because you have created two different methods with different selectors:
-AddMethod::andAddMethod:. There is a colon for each interleaved parameter. It’s normal to put some text in also e.g.-addMethodX:Y:but you don’t have to.