I am a beginner. And I was trying to transform arabic numbers to ordinal numbers by having the following class.
num is NSInteger, while, during the calculation, the warning pop out "local declaration of '' hides instance"
#import "ordinalNumberFormatter.h"
@implementation ordinalNumberFormatter
- (NSString*)ordinalNumberFormatter:(NSInteger)num
{
NSString *ending;
int ones = num % 10; //Warning came out
int tens = floor(num / 10); //Warning came out
tens = tens % 10;
if(tens == 1){
ending = @"th";
}else {
switch (ones) {
case 1:
ending = @"st";
break;
case 2:
ending = @"nd";
break;
case 3:
ending = @"rd";
break;
default:
ending = @"th";
break;
}
}
return [NSString stringWithFormat:@"%d%@", (int)num, ending]; //Warning came out
}
@end