ios - How do I convert an array of ints to a NSString in Objective c? -
first off, i'm pretty new coding bear me if dumb question. don't know how convert soemthing int array[10] single nsstring. i've been searching solutions, far, i've seen converting array string array.
first thing tried like
nsstring *string=[nsstring stringwithformat @"%i",array];
but thing is, know can like
nsstring *string[nsstring stringwithformat @"%i%i%i...",array[0],array[1],array[2],.....];
but i'm trying avoid since doing more 10 variables , doing quite bit seperately named variables
int i[] = {1,2,3,4,5,6,7}; int len = sizeof(i) / sizeof(int); nsmutablestring * str = [nsmutablestring string]; (int j = 0; j<len; j++) { [str appendformat:@"%i ", i[j]]; } nslog(@"%@",str);
Comments
Post a Comment