ios - How to calculate same substring from given entire NSString -


i wan calculate total white space in given string.if total white space more 1 want replace 2nd number of space "\n"

for example: my string : "i iphone" . string contains 3 space. want o/p "i \niphone".

this example. string not static. give string dynamic how can implement ??

thanks in advance

nsstring *givenstring = @"i iphone ok"; nsarray *stringarray = [givenstring componentsseparatedbystring:@" "];  nsstring *string = @"";  (int = 0; i<stringarray.count; i++) {     string = i==2 ? [nsstring stringwithformat:@"%@\n%@",string,stringarray[i]] : [nsstring stringwithformat:@"%@ %@",string,stringarray[i]]; }  nslog(@"%@",string); 

hope helps!


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -