I'm checking is first letter of string is 0, if it is remove it and call again method to check is there is still 0. I've debugged this and it seems like when it accomplish number without 0, it goes backwards. Code:
-(NSString *)deleteZerosOnFirst:(NSString *)card
{
NSString *firstLetter = [card substringToIndex:1];
if ([firstLetter isEqualToString:@"0"]) {
card = [card substringFromIndex:1];
[self deleteZerosOnFirst:card];
NSLog(@"CARD: %@", card);
return card;
}
else {
NSLog(@"CARD: %@", card);
return card;
}
}
Aucun commentaire:
Enregistrer un commentaire