DocAsh59
DocAsh59

Reputation: 400

Get the objectId of a newly saved PFObject

I am using latest Parse SDK and am sending data to the Cloud Data.
This is my code at the moment but am unsure how to retrieve the objectId upon success:

PFObject *testObject = [PFObject objectWithClassName:@"CLASS_NAME"];
testObject[@"Name"] = firstName;
testObject[@"LastName"] = lastName;

[testObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) 
{
    if (succeeded) 
    {
        //success trigger
    }
}];

Upvotes: 2

Views: 341

Answers (1)

Simon McLoughlin
Simon McLoughlin

Reputation: 8465

its inside:

PFObject *testObject

access it with

NSLog(@"objectID: %@", testObject.objectId);

see: https://parse.com/docs/ios/api/Classes/PFObject.html#//api/name/objectId

Upvotes: 5

Related Questions