In my code I have an NSMutableArray. I want to get all values from that array into String and I want to send to the server. I used a for loop but it doesn't work. I don't know what I did wrong. Please help to fix the issue.
Here the code I tried.
var newString1 = String()
for i in (0..<self.idMutableArray.count)
{
newString1 = (idMutableArray.object(at: i) as! NSString) as String
print("newString1 is ",newString1)
}
print("newString1 is ",newString1)
The mutable array Format is:
idMutableArray is (
31,
30,
29,
42,
50
)
When I am tried I get this format:
newString1 is 29
newString1 is 30
newString1 is 31
newString1 is 42
newString1 is 50
But I want to send this format to the server.
newString1 = 31,30,29,42,50
I don't know how to change that array to string format. Please help me.
NSMutableArrayinstead of a Swift array? WhyNSStringinstead ofString?for i in idMutableArray { newString = i as! NSString }componentsJoined(orjoinedfor a Swift array).