6

I am kind stuck with the following.

I've got the following array

var selectedItems = Set<String>()

That has some items from parse inserted to it

self.selectedItems.insert(objectToAppend)

Then I've created the following variable where I intend to convert the Set into something I could use on my parse query with the following line. But almost nothing converts. [AnyObject, [String], [self.selectedHobbies], ["\(self.selectedHobbies)"] ... none works.

let itemsArray = self.selectedHobbies as [AnyObject]

And if I do not convert it I cannot use in the query bellow.

query.whereKey("itemTag", containedIn: itemsArray as [AnyObject])

If I could manage to convert it to a [String] it would solve my problem. Not sure how.

GuiSoySauce
  • 1,643
  • 2
  • 21
  • 35
  • 1
    Is this what you are looking for http://stackoverflow.com/questions/29046695/swift-1-2-set-to-array ? – Martin R Aug 20 '15 at 03:40

1 Answers1

15

When in doubt, try the init!

let selectedItems: Set<String> = ["One", "Two", "Three"]
let arr = [String](selectedItems)
Mr Beardsley
  • 3,417
  • 18
  • 27