NSRange rangetxt={0,(index-1)};
NSString *tempStr= textBox.text;
NSString *tempTextBox=[tempStr substringWithRange:rangetxt];
Hi Everyone,
I want to know why my pasted code isn’t working properly, when the compiler passes substringWithRange It hung up and do not assign any value to tempTextBox, Secondly I’ve tried the NSString function substringToIndex as well yet its not working too, My objective is to skip the last character while copying tempStr to tempTextBox.
Regards
MGD
You don’t show the code that’s initialising
index. My guess is it’s out of range. Note that substringWithRange raises anNSRangeExceptionif any part of the range lies beyond the end of the receiver.Try this: