i have label , nsmutable set.
i want assign set value 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 have tried joined , throws compile time error.
please provide me alternative way in swift
first of answer question: have write
(mutset.allobjects as! [string]).joined(separator: "\n")
ns(mutable)set
lacks type information. have cast type actual [string]
it's highly recommended use native set
, discouraged using nsmutable...
types if there native counterpart.
var mutset = set<string>(["a", "b", "c"])
you can append (actually insert
) item - set unordered
mutset.insert("d")
or array of items
mutset.formunion(["c", "d", "f"])
joining shorter in foundation nsmutableset
mutset.joined(separator: "\n")
or sorted joined
mutset.sorted().joined(separator: "\n")
Comments
Post a Comment