title: How to prevent duplicate entry on parse?
body: <p>I' trying to save song info to parse, but if the song already exist in parse I want my code just do nothing. </p>
  
  <p>I've tried this code below:</p>
  
  <pre><code>var Music = PFObject(className:"Musics")
          var query = PFQuery(className:"Musics")
          query.findObjectsInBackgroundWithBlock {
              (objects: [AnyObject]?, error: NSError?) -&gt; Void in
  
              if error == nil {
                  // The find succeeded.
                  println("Successfully retrieved \(objects!.count) scores.")
                  // Do something with the found objects
                  if let objects = objects as? [PFObject] {
                      for object in objects {
  
  
                          var songTitle = object.objectForKey("songTitle") as? String
  
                          if songTitle != title {
  
                              Music["createdBy"] = PFUser.currentUser()
                              Music["songTitle"] = title
                              Music["albumCover"] = imageFile
                              Music["songArtist"] = artist
                              Music.saveInBackgroundWithBlock {
  
                                  (success: Bool, error: NSError?) -&gt; Void in
                                  if (success) {
  
                                      println("succeed")
  
                                  } else {
                                      // There was a problem, check error.description
                                      println("error jeh")
                                  }
                              }
  
                          }else{
  
                              println("song already exist")
  
                          }
  
                      }
                  }
              } else {
                  // Log details of the failure
                  println("Error: \(error!) \(error!.userInfo!)")
              }
          }
  </code></pre>
  
  <p>the code above give below result on log:</p>
  
  <blockquote>
    <p>Successfully retrieved 4 scores.
    song already exist
    Successfully retrieved 4 scores.
    song already exist
    Successfully retrieved 4 scores.
    song already exist
    Successfully retrieved 4 scores.
    song already exist
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed
    succeed</p>
  </blockquote>
  
  <p>Why my for loop , looping more than the Objects.count? and how can  I prevent dupiclate entry on parse?</p>
  
  <p>give me any advice, doesn't matter in obj c or swift</p>