Backendless Support
 
Answered

How can I get an objectId using asynchronous method for saving it?

I need to get an objectId of the object that just has been created with asynchronous method, but response returns me null for objectId.

  1. guestTable *guest = [guestTable new];
  2. guest.title = _someText;
  3. @try {
  4. [backendless.persistenceService save:guest response:^(id response) {
  5. NSLog(@"%@", response);
  6. }
  7. error:^(Fault *fault) {
  8. NSLog(@"FAULT = %@ <%@>", fault.message, fault.detail);
  9. }];

Best Answer
photo

Hello Vasilii,

Please, check this code:

  1. guestTable *guest = [guestTable new];
  2. guest.title = @"title";
  3. [backendless.persistenceService save:guest
  4. response:^(guestTable *response) {
  5. NSLog(@"%@", response.objectId);
  6. }
  7. error:^(Fault *fault) {
  8. NSLog(@"FAULT = %@ <%@>", fault.message, fault.detail);
  9. }];

Regards

Olga

Leave a Comment

Comments (5)

photo
1

Hello,

What does the guestTable class look like?

Mark

photo
1

Mark, just a few NSStrings. Shall I remove an objectId NSString?

  1. @interface guestTable : NSObject
  2. @property (nonatomic, strong) NSString *title;
  3. @property (nonatomic, strong) NSString *objectId;
  4. @end

photo
photo
1

Hello Vasilii

I've contacted our iOS team to investigate your question. They will contact you ASAP! Thanks for patience

Regards Anton

photo
1

Hello Vasilii,

Please, check this code:

  1. guestTable *guest = [guestTable new];
  2. guest.title = @"title";
  3. [backendless.persistenceService save:guest
  4. response:^(guestTable *response) {
  5. NSLog(@"%@", response.objectId);
  6. }
  7. error:^(Fault *fault) {
  8. NSLog(@"FAULT = %@ <%@>", fault.message, fault.detail);
  9. }];

Regards

Olga

photo
1

Olga,

Thank you, it works!

photo