i have a string like 112.1 or 102.2 etc now i want to get the substring before dot and after the dot using objective c, means i want to get 2 substrings like this 112 and 1. please guide. Regards Saad.
Try the following:
NSArray *arrayWithTwoStrings = [yourString componentsSeparatedByString:@"."];
Using this method you'll get NSArray containing string components that were separated by "." string, that is "112" and "1" for "112.1" string. After that you can access them using array's objectAtIndex:
method.
P.S. Note also that if you're going to use numeric values of those strings there might be better solution
NSString *str = yourstr;
NSArray *Array = [str componentsSeparatedByString:@"."];
NSString *t = [Array objectAtIndex:0];
NSString *t1 = [Array objectAtindex:1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With