title: Saving Arrays to and retrieving from Parse in swift
body: <p>My app contains WordLists with associated Words in CoreData. I can upload them to Parse to share them, but i am struggling to get them out from Parse again and back into CoreData. </p>
  
  <p>To save all the words associated to a wordlist to parse I have: </p>
  
  <pre><code>parseWordList.setObject("\(wordList?.words?.valueForKey("wordName"))", forKey: "Words") 
  </code></pre>
  
  <p>which saves as a string, but looks like a set in Parse which has confused me?</p>
  
  <p><a href="https://i.stack.imgur.com/19LF7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/19LF7.png" alt="enter image description here"></a></p>
  
  <p>Then when I query the list again I am struggling to covert to an array so I can iterate through it and save it back into CoreData.</p>
  
  <p>How do I convert the Parse Words string/set? back to an array, and how do I get rid of the 'Optional' prefix when saving to Parse?</p>
  
  <p>Thanks in advance to anyone who can help me...</p>
  
  <pre><code>let query = PFQuery(className: "WordList")
      query.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) -&gt; Void in
  
          if error == nil &amp;&amp; objects != nil {
                  for object in objects! {
  
                      let joinedWords = object.objectForKey("Words")
                      let joinedWordsArray = Array(arrayLiteral: joinedWords)
  
                      let wordEntity = NSEntityDescription.entityForName("Word", inManagedObjectContext: self.coreDataStack.managedObjectContext)
  
                      for joinedWord in joinedWordsArray {
                          let word = Word(entity: wordEntity!, insertIntoManagedObjectContext: self.coreDataStack.managedObjectContext)
                          word.wordName = joinedWord as? String
                          word.wordList = joinedWordList
      }
                  }
          } else {
              print("Error")
          }
      }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/KzJbw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KzJbw.png" alt="enter image description here"></a></p>