title: Fetching data from parse and storing it to Core Data
body: <p>I'm trying to store some data to Core Data which is fetched from Parse as shown in below code.</p>
  
  <pre><code>func storeAllDataFromParseToCore(){    
      let context : NSManagedObjectContext = appDel.managedObjectContext!
      let insertNew = NSEntityDescription.insertNewObjectForEntityForName("SomeEntity", inManagedObjectContext: context) as! NSManagedObject
      let query = PFQuery(className: "SomeClass")
      query.selectKeys(["Name","Image","Type"])
      query.findObjectsInBackgroundWithBlock({(dummyObjects : [AnyObject]?,error :NSError?)-&gt; Void in
          if error == nil {
              for obj : AnyObject in dummyObjects! {
                  println(dummyObjects?.count)
                  insertNew.setValue(obj.objectForKey("Name"), forKey: "name")
                  insertNew.setValue(obj.objectForKey("Type"), forKey: "type")
                  let res = context.save(nil)
                  println("before \(res)")
                  let file : PFFile = obj.objectForKey("Image") as! PFFile
  
                  file.getDataInBackgroundWithBlock({(data : NSData?, error : NSError?)-&gt; Void in
                       insertNew.setValue(data, forKey: "image")
                          let val = context.save(nil)
                      println(val)
                  }) 
              }
          }
      })
  }
  </code></pre>
  
  <p>When I save it always returns true but when I fetch again from core data not all images and names are getting stored. eg: If I have 2 images and corresponding name in parse, only one is getting stored. 
  In console it prints as shown below.</p>
  
  <pre><code>optional(2)
  before true
  optional(2)
  before true
  true
  true
  </code></pre>
  
  <p>Since its returning true I'm thinking all the data is getting stored. But when I retrieve only one image will be stored.I don't understand how to resolve this. Please help me!</p>