Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let okAction = UIAlertAction(title: "Enter", style: UIAlertActionStyle.Default, handler: {(alert :UIAlertAction!) in
- let query = PFQuery(className: "Playlists")
- query.whereKey("createdbyuser", equalTo: (PFUser.currentUser()?.username!)!)
- query.whereKey("playlistName", equalTo: self.inputTextField.text!)
- query.findObjectsInBackgroundWithBlock {(objects: [PFObject]?, error: NSError?) -> Void in
- if ((error) == nil)
- {
- dispatch_async(dispatch_get_main_queue(), {
- if (objects!.count == 0)
- {
- let object = PFObject(className: "Playlists")
- object["playlistName"] = self.inputTextField.text!
- object["createdBy"] = PFUser.currentUser()!
- object["track"] = []
- object.saveInBackgroundWithBlock({ (success, error) in
- if(error == nil)
- {
- let control = self.storyboard!.instantiateViewControllerWithIdentifier("singlePlaylistVC") as! SinglePlaylistViewController
- control.object = object
- self.navigationController!.pushViewController(control, animated: true)
- }
- })
- }
- else
- {
- print("You have already created this playlist")
- }
- })
- }
- else
- {
- print(error?.description)
- }
- }
- })
- alertController.addAction(okAction)
- presentViewController(alertController, animated: true, completion: nil)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement