Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Why isn't my swift code saving the Parse object I want it to?

Hello everyone. I'm working on this iOS app and now when I run the app and go to the second tab, my app doesn't save this test Parse object I'm creating here. Can you tell me what I'm doing wrong? My Console doesn't print anything. How can I know my code is getting executed at all? I'm a bit puzzled. I'll be happy if you can help me with this issue. Thanks in advance.

import UIKit
import Parse

class FaSecondViewController: UIViewController {

    override func viewDidLoad()
    {
        super.viewDidLoad()

        let object = PFObject(className:"Cats")
        object["title"] = "a"
        object["description"] = "b"
        object["image"] = "test"

        object.saveInBackgroundWithBlock
        {
            (success: Bool, error: NSError?) -> Void in
            if (success)
            {
                print("Saved")
            }
            else
            {
                print("Error")
            }
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}