How to remove delete whole row using code ios

I would like to delete whole row from a class .

Here’s how to do it:

http://support.backendless.com/public/attachments/3c9440c39c93294d62075542d3962f05.png</img>

What about using code ?

It is in the docs:https://backendless.com/documentation/data/rest/data_deleting_data_objects.htm

i would like to ask another is that to upload current user relation i user backendless.userservice.currentUser and what about other user i want to upload as relation . I use fromUser.objectId = objectId which does not succeed

Are you asking how to relate current user to another user?

Basically Ya

Do you use Java?

IOS swift/obj-C

Here’s an example:

let currentUser = backendless.userService.currentUser
let otherUser = backendless.data.of(BackendlessUser.ofClass()).findID("xxxxx-xxxxx")
currentUser.setProperty("friend", object: otherUser)
backendless.userService.update(currentUser)

Terminating app due to uncaught exception of class ‘Fault’

libc++abi.dylib: terminating with uncaught exception of type Fault

And Here Is my Code
Can you tell me where i wrong ?










            let activity = Activity()

            activity.fromUser = backendless.userService.currentUser

            activity.toUser = backendless.userService.findById("\(searchUserId)")

            activity.type = "follow"

            let activityStore = backendless.data.of(Activity.ofClass())

        

            // now delete the saved object

            activityStore.remove(

                activity,

                response: { (result: AnyObject!) -> Void in

                    print("Contact has been deleted: \(result)")

                },

                error: { (fault: Fault!) -> Void in

                    print("Server reported an error (2): \(fault)")

            })

The code does not make sense. You created a brand new Activity object (which does not exist on the server) and trying to delete it on the backend.

I just wanna delete the specific object with that the data that matches my condition

You either need to lookup (retrieve from server) that object first or you need to know it’s objectId.

I know it objectId which searchUserId from above

searchUserId is the objectid for the Activity object? Just the naming alone does not sound right. Do you know objectId of the Activity object you need to delete?

Did you read this documentation?
https://backendless.com/documentation/data/ios/data_deleting_data_objects.htm

Mark

activity.toUser
toUser is a data object relational to Users Class / I am deleting the whole row by matching if the toUser object has the objectId (which is from Users Class) that matches the searchObjectId .if matches i would like to delete the whole row .

Run a query first to load the object which you will be deleting. Use the whereClause query:

toUser.objectId = ‘/(backendless.userService.currentUser.objectId)’

Once you have the object, use the API to delete it

activity has no member where clause and
here is the activity class









class Activity : NSObject {

    

    var fromUser : BackendlessUser?

    var toUser : BackendlessUser?

    var type : String?

    var objectId : String?

    var created : NSDate?

    var updated : NSDate?

    var ownerId : String?

}

Read about whereClause here: https://backendless.com/documentation/data/ios/data_search_and_query.htm