creating data ios sdk

5 posts, 0 answers
  1. Anne Sophie
    Anne Sophie avatar
    16 posts
    Member since:
    Oct 2015

    Posted 10 Feb Link to this post

    I am struggling  with the backend services api. My latest problem is with creating a data entry to add to a content type. the create method listed in the docs appears to be missing or deleted from the api. See line 61 of screenshot. as for the method that is in the api what is a selector that is mentioned in the 2nd and 3rd parameters. 
  2. Dimitar Dimitrov
    Admin
    Dimitar Dimitrov avatar
    26 posts

    Posted 12 Feb Link to this post

    Hi Diego,

    The create item functionality is essential to the iOS SDK and I think that it might be a bug of xcode, that you don't see the definition of the function. Here a snippet of how it actually looks.
    /*!
     Creates a new EVObject in background.
     @param object The object to be created.
     @param block The block to execute. The block should have the following argument signature: (BOOL success, NSError *error)
     */
    - (void)create:(id)object block:(EVObjectResultBlock)block;
     
    /*!
     Saves a new EVObject in background.
     @param object The object instance to be created in everlive.
     @param target The object to call selector on.
     @param selector The selector to call. It should have the following signature: (void)requestCompletedWithResult:(id)result error:(NSError*)error. error will be nill on success.
     */
    - (void)create:(id) object target:(id) target selector:(SEL)selector;


    You can just use the first definition with a block callback. Here is an example how it is done:
    let dataStore: EVDataStore = EVDataStore.sharedInstance() as! EVDataStore
             
            //Create item
            let newMessage:Message = Message.init();
            newMessage.content = "New message content"
            newMessage.createdByName = "John Doe"
             
            dataStore.create(newMessage) { (success:Bool, error:NSError!) -> Void in
                if(success){
                    print("message created")
                }else{
                    print("error \(error)")
                }
            }

    Basically you need to get an instance of our data store, that takes care of creating new items. Then create an instance of your class and populate it with the values you want and pass it to the create function of the dataStore. In the callback you'll receive either an error or a success variable that indicates if the creation was completed successfully.

    I hope you'll find this example helpful. If you need more information, do not hesitate to contact us.

    Regards,
    Dimitar Dimitrov
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Anne Sophie
    Anne Sophie avatar
    16 posts
    Member since:
    Oct 2015

    Posted 12 Feb in reply to Dimitar Dimitrov Link to this post

    Dont see how it could be an xcode bug it said dataStore has no member create with the given parameters and i also opened the datastore.h in the everlive sdk and the method wasnt in the file there. can i just paste the above create method (first one) in to this file?
  4. Anne Sophie
    Anne Sophie avatar
    16 posts
    Member since:
    Oct 2015

    Posted 12 Feb in reply to Anne Sophie Link to this post

    **i also opened the datastore.h in the everlive sdk in a text editor and the method wasnt in the file there either.

    sorry should proof read my post.

  5. Dimitar Dimitrov
    Admin
    Dimitar Dimitrov avatar
    26 posts

    Posted 12 Feb Link to this post

    Hi Diego,

    I am attaching a fresh build of the iOS SDK that contain the above mentioned declaration of the method. I don't know how it is possible to be absent, without manually deleting it.

    Would you please try the version I am sending in your project and tell me if any problems persist.

    Regards,
    Dimitar Dimitrov
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
Back to Top