title: How to get the Object ID in Parse
body: <p>I tried to find the objectID in the background so I can successfully unpin and delete the object in the background. However the objectID is for some reason returning a nil value and thus resulting in the app to crash.</p>
  
  <p>Here is some code - </p>
  
  <p>(imagesToDelete is an array of PFFile)</p>
  
  <pre><code>      for object in imagesToDelete
        {
              var imageObject = PFObject(className: "img")
              imageObject["theImg"] = object
                 //Object ID Returns nil
               var objID = imageObject.objectId
  
              //fatal error: unexpectedly found nil while
              imageObject.removeObjectForKey(objID!)
              imageObject.unpinInBackgroundWithBlock({ (success, error) -&gt; Void in
                  if error == nil
                  {
                      imageObject.deleteEventually()
                      println("Objects deleted!")
                  } 
                 else 
                  {
                      println(error)
                  }
  
              })
  
          }
  </code></pre>