I'm working on a project that turns numbers to words as a training exp. But I'm facing a problem, I'm using a method to collect first 3 chars as shown bellow:
Code:
NSString *a=[[NSString alloc]initWithFormat:@"%d",[snumber characterAtIndex:(0,3)]];
int millions = (int)a;
NSString *s=[[NSString alloc]initWithFormat:@"%d",[snumber characterAtIndex:(3,6)]];
int hundredThousands = (int)s;
NSString *d=[[NSString alloc]initWithFormat:@"%d",[snumber characterAtIndex:(6,9)]];
int thousands = (int)d;
but I keep getting the out of range error below:
Code:
2010-09-02 19:29:20.773 convert[412:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString characterAtIndex:]: Range or index out of bounds'
and the throws.