How to convert NSArray into NSString in objective-c?
In Swift, the NSArray class conforms to the ArrayLiteralConvertible protocol, which allows it to be initialized with array literals. For more information about object literals in Swift, see Literal Expression in The Swift Programming Language (Swift 4.1).
arrays can't contain nil. There is a special object, NSNull ( [NSNull null] ), that serves as a placeholder for nil.
NSArray(NSCoder) A constructor that initializes the object from the data stored in the unarchiver object.
In Objective-C, arrays take the form of the NSArray class. An NSArray represents an ordered collection of objects. This distinction of being an ordered collection is what makes NSArray the go-to class that it is.
Swift 3.0 latest updates
let string = array.componentsJoined(by: ",")
you can used any separator in function which you want to separate the array elements currently in above example is ",".
Bearing in mind that you don't say what's in the NSArray, you can do this:
NSArray *arr = [NSArray arrayWithObjects: @"foo", @"bar", @"baz"];
[arr componentsJoinedByString: @","]
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