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
Tom Coomer
1,331 PointsGet Object Id from Parse
I would like to get the object id from parse when the object is created. The code below works except from the "println()" line. It simply prints "nil"
var myObject = PFObject(className:"Objects")
myObject["category"] = categoryTextField.text
myObject["date"] = date
myObject.saveInBackground()
var createdId = myObject.objectId
println(createdId)
}
Thanks
2 Answers
obey me
1,135 PointsI used to have the same error but the solution is to first PFQuery the object then call query.findObjectsInBackgroundWithBlock PFObject object then inside of the code block you call your PFObject code . then println() to check error
i hope it helps
dungeonkeeperhf
3,272 PointsThe reason you're getting this error is because you're saving the object but not retrieving it. Look into the retrieving objects on the Parse documentation.
Tom Coomer
1,331 PointsTom Coomer
1,331 PointsHow do I query the object without knowing the id?