How to remove delete whole row using code ios

Am i correct ?

 
 
 
 
 
 
 
 
 let query = BackendlessDataQuery() 
 
 query.whereClause = "fromUser.objectId = '\(backendless.userService.currentUser.objectId)' AND toUser.objectId = '\(searchUserId)' AND type = 'follow'"
 
 let activityStore = backendless.data.of(Activity.ofClass()) 
 
 // now delete the saved object 
 
 activityStore.remove( 
 
 query, 
 
 response: { (result: AnyObject!) -> Void in 
 
 print("Contact has been deleted: \(result)") 
 
 }, 
 
 error: { (fault: Fault!) -> Void in 
 
 print("Server reported an error (2): \(fault)") 
 
 })


No, this is not correct. You need to (1) retrieve object first, then (2) delete it.

Ok I get what you mean am i doing correct cause i am getting this error

FAULT = ‘2024’ [Wrong entity name: name must not have a symbol ‘.’] <Wrong entity name: name must not have a symbol ‘.’>












            let query = BackendlessDataQuery()

            query.whereClause = "fromUser.objectId = '\(backendless.userService.currentUser.objectId)' AND toUser.objectId = '\(searchUserId)' AND type = 'follow'"

            

            Types.tryblock({ () -> Void in

            

            let users = backendless.persistenceService.of(Activity.ofClass()).find(query)

            let currentPage = users.getCurrentPage()

                for test in currentPage as! [Activity] {

                    

                    delete = test.objectId!

                    

                }

            print("Loaded \(currentPage.count) USers objects")

            print("Total Follow users in the Backendless starage - \(users.totalObjects)")

            

            

            

            

            },

            

            catchblock: { (exception) -> Void in

            print("Server reported an error: \(exception as! Fault)")

            }

            )

  

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

            




                // now delete the saved object

            activityStore.remove(

                delete,

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

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

                },

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

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

            })




            

It looks much better now! Can you show what you get in the XCode log?

Also, is the Activity class defined in a separate .swift file?

Xcode Log

Loaded 1 USers objects

Total Follow users in the Backendless starage - 1

Server reported an error (2): FAULT = ‘1033’ [Unable to remove object. Object with the specified primary key does not exist] <Unable to remove object. Object with the specified primary key does not exist>

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?

}

Anyway i solved it instead of remove i change it to removeID