Hi! I override default Event Handler for creating object(just add print in console). hen i create object with REST request handlers work. Event handler is not called if i use iOS SDK and ‘save’ method.
Do you run CodeRunner locally (debug mode) or published your event handler to production?
I run CodeRunner locally
Can you post here complete output of the CodeRunner utility (from the moment you start it)
Listening for transport dt_socket at address: 5005
[INFO] CodeRunner™ Backendless Debugging Utility
[INFO] Copyright© 2016 Backendless Corp. All rights reserved.
[INFO] Version: 3.0.0 Build date: 20160125-0901
[INFO] CodeRunner session is running for 2 hour and will be terminated on 21:26:11.763[UTC]
[INFO] Registering runner on: https://api.backendless.com with secretKey: XXXX-XXXXXX
[INFO] Runner successfully registered
[INFO] Parsing event model…
[INFO] Build successfully: EventModel{timers=0, eventHandlers=5}
[INFO] Deploying model to server, and starting debug…
[INFO] Model successfully deployed…
[INFO] Waiting for events…
I repeat that when i send REST request handlers work.
I assume you verified that the save call from iOS is structurally identical to the one with REST. How complex is the data object you’re sending from iOS? Could you post the source code for the class you’re sending here? Also, if you could attach the event handler where you expect to handle the save operation, it would be great.
Ok,
This my object
@interface Order : BaseModel
@property (strong, nonatomic) NSString* address;
@property (strong, nonatomic) NSString* descript;
@property (strong, nonatomic) NSString* comment;
@property (nonatomic) BOOL isCancel;
@property (nonatomic) BOOL isClosed;
@property (strong, nonatomic) NSDate* perform;
@property (strong, nonatomic) NSString* type;
//@property (strong, nonatomic) UIImage* image;
@end
// use save
Order *o = [Order new];
id<IDataStore> dataStorage = [backendless.persistenceService of:[Order class]];
[dataStorage save:ord];
//business logic
@Asset( “Order” )
public class OrderTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<Order>
{
@Override
public void afterCreate( RunnerContext context, Order order, ExecutionResult<Order> result ) throws Exception
{
order.setAddress(“swdwede333-4-=p3324”);
}
}
Is this a typo or that’s how you have it in your code?:
[dataStorage save:ord];
I thought it should be:
[dataStorage save:o];
I’m sorry, you right
[dataStorage save:o];
(ord is Order object but with other data)
still same result after the change? Btw, what’s in the BaseModel class?
Also, is the object saved in the table?
Yeah, object save in table (this fact is very strange)
BaseModel just
@interface BaseModel : NSObject
@property (nonatomic, strong) NSString *objectId;
@property (nonatomic, strong) NSDate *created;
@property (nonatomic, strong) NSDate *updated;
@property (nonatomic, strong) NSString *ownerId;
@end
Thanks, Misha. I am assigning this to our QA who will start by reproducing the problem. We will let you know what we find out.
Thank you
Hi Misha!
Could you try to use create method instead of save?
Hi Misha,
We have investigated the problem and fixed it. The fix
would be present in the next upcoming release. At the moment please try
workaround posted above by Kate.
Regards, Artur.
In iOS SDK, the method for storing objects is declared in @protocol IDataStore, which doesn’t contain any create methods, only save. So, can you please clarify what exactly do you propose to use instead?
Edit: found, method is in PersistenceService class. I’ve tested - workaround works, thank you!
Hi Guys,
Im having the same problem (just opened a new topic for it). The workaround that Kate suggests doesn’t work as there is no create method as Misha already mentioned.
Hi Vasyl,
You’re correct indeed. Using the mentioned create method does work. However, the save method also used to work until yesterday for me.
Thanks!
- It wasn't Misha, it was me who mentioned absence of create method :)
Method actually exists and workaround works, see my edit above.
This is already fixed internally. We will be rolling it out in the next update of the service next week.