title: Why is the function in the background not being called?
body: <p>I have a program which will record the song title and artist of the currently playing song on the itunes app, but when I click the home button the app does not record the title or the artist anymore. The background function works because when I click the home button the test function works, but for some reason the getNowPlayingItem does not work. How do I fix this?</p>
  
  <pre><code>  var musicPlayer = MPMusicPlayerController.systemMusicPlayer()
  
    func applicationDidEnterBackground(application: UIApplication) {
      print("entered background")
  
      NSNotificationCenter.defaultCenter().addObserver(self, selector: "getNowPlayingItem", name: MPMusicPlayerControllerNowPlayingItemDidChangeNotification, object: nil)
      musicPlayer.beginGeneratingPlaybackNotifications()
  
  
      test()
  }
  
  func test(){
        print("Background function working")
          }
  
  func getNowPlayingItem() {
      if  let nowPlaying = musicPlayer.nowPlayingItem  {
          let title = nowPlaying[MPMediaItemPropertyTitle] as? String
          let artisttest = nowPlaying[MPMediaItemPropertyTitle]
          if let artist = nowPlaying[MPMediaItemPropertyArtist] as? String{
  
              let objectPointer = PFObject(className: "Pointer")
              let object = PFObject(className: "MasterSongs")
  
              //    print("Artist: " + artist)
  
  
              let query = PFQuery(className: "Pointer")
              query.findObjectsInBackgroundWithBlock({
                  (objects: [AnyObject]?, error: NSError?) -&gt; Void in
                  var objectIDs = objects as! [PFObject]
  
                  for i in 0...objectIDs.count-1{
                      self.Parsearray.append((objectIDs[i].valueForKey("title") as? String)!)
  
                      // print(self.Parsearray)
                  }
  
  
                  if self.Parsearray.contains(title!){
                      print("already in db")
                  }else{
                      objectPointer["title"] = title
                      objectPointer["user"] = PFUser.currentUser()
                      objectPointer["artist"] = artist
                      objectPointer.saveInBackground()
  
  
                  }
  
              })
  
  
  
  
          }else{
              let object = PFObject(className: "MasterSongs")
              object.setObject(title!, forKey: "title")
              //object.setObject(artist!, forKey: "artist")
              object.saveInBackground()
  
              let objectPointer = PFObject(className: "Pointer")
  
  
              let query = PFQuery(className: "Pointer")
              query.findObjectsInBackgroundWithBlock({
                  (objects: [AnyObject]?, error: NSError?) -&gt; Void in
                  var objectIDs = objects as! [PFObject]
  
                  for i in 0...objectIDs.count-1{
                      self.Parsearray.append((objectIDs[i].valueForKey("title") as? String)!)
  
                      // print(self.Parsearray)
                  }
  
  
                  if self.Parsearray.contains(title!){
                      print("already in db")
                  }else{
                      objectPointer["title"] = title
                      objectPointer["user"] = PFUser.currentUser()
                      objectPointer["artist"] = "No artist found :("
                      objectPointer.saveInBackground()
  
  
                  }
  
              })
  
  
  
  
  
          }
  
  
      }
  
  
  }
  </code></pre>