× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Store Data From Parse.com Into an Array in Swift

Stefan DeClerck
Jul 05, 2015
<p>Hi everyone. Every once in a while I need to look up how to store data from Parse.com into an array in swift.</p> <pre><code>//Create an empty array var myArray: [String] = [String]() //Get the data from the PFQuery class var query = PFQuery(className: "ClassName") query.findObjectsInBackgroundWithBlock{ (objects: [AnyObject]?, error: NSError?) -&gt; Void in if error == nil { if let objects = objects as? [PFObject] { for object in objects { //For each object in the class object, append it to myArray self.myArray.append(object.objectForKey("ClassNameObject") as! String) } } } else { println("\(error?.userInfo)") } }</code></pre> <p> </p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus