First off, I'm pretty new to coding so bear with me if this is a dumb question. I don't know how to convert soemthing like int array[10] into a single NSString. I've been searching for solutions, but so far, all i've seen is converting from an array to an string array.
First thing I tried was something like
NSString *String=[NSString stringWithFormat @"%i",array];
But the thing is, i know that I can do something like
NSString *String[NSString stringWithFormat @"%i%i%i...",array[0],array[1],array[2],.....];
But i'm trying to avoid that since I will be doing this for more than 10 variables and I will be doing it quite a bit with seperately named variables
int i[] = {1,2,3,4,5,6,7};
int len = sizeof(i) / sizeof(int);
NSMutableString * str = [NSMutableString string];
for (int j = 0; j<len; j++) {
[str appendFormat:@"%i ", i[j]];
}
NSLog(@"%@",str);
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