I have label and NSMutable Set.
I want to assign my set value to label.text.
@IBOutlet var location: UILabel!
var mutSet:NSMutableSet = NSMutableSet()
self.location.text = **mutSet.allObjects.componetsJoinedByString("\n")**
mutSet.allObjects.componetsJoinedByString("\n") throws compile time error similarly I have tried joined , it also throws compile time error.
Please provide me alternative way in Swift
First of all to answer your question: You have to write
NS(Mutable)Set
lacks any type information. You have to cast the type to actual[String]
It's highly recommended to use native
Set
and generally you are discouraged from usingNSMutable...
types if there is a native counterpart.You can append (actually
insert
) an item - a set is unorderedor an array of items
Joining is much shorter than in Foundation
NSMutableSet
or sorted joined