Deleting a KiiObject

You can delete a KiiObject by calling the delete(_:) method:

Swift 3:

  • // Instantiate a KiiObject with its URI.
    let object = KiiObject(uri: "Set the URI of an existing KiiObject here")!
    
    do{
      // Delete the KiiObject.
      try object.deleteSynchronous()
    } catch let error as NSError {
      // Handle the error.
      return
    }
  • // Instantiate a KiiObject with its URI.
    let object = KiiObject(uri: "Set the URI of an existing KiiObject here")!
    
    // Delete the KiiObject.
    object.delete { (object : KiiObject?, error : Error?) -> Void in
      if error != nil {
        // Handle the error.
        return
      }
    }

Objective-C:

  • // Instantiate a KiiObject with its URI.
    KiiObject *object = [KiiObject objectWithURI:@"Set the URI of an existing KiiObject here"];
    
    NSError *error;
    
    // Delete the KiiObject.
    [object deleteSynchronous:&error];
    if (error != nil) {
      // Handle the error.
      return;
    }
  • // Instantiate a KiiObject with its URI.
    KiiObject *object = [KiiObject objectWithURI:@"Set the URI of an existing KiiObject here"];
    
    // Delete the KiiObject.
    [object deleteWithBlock:^(KiiObject *object, NSError *error) {
      if (error != nil) {
        // Handle the error.
        return;
      }
    }];

A KiiObject will be deleted from the server by calling the delete(_:) method; you do not need to invoke the save(_:) method.

If you delete a KiiObject which has an object body, the body will be deleted at the same time. If the object body has been published, its URL will be disabled too. See Deleting an Object Body for more details.

Although there is no API for bulk-deleting multiple KiiObjects, you can delete all KiiObjects in a bucket at once by deleting the bucket. See Deleting a Bucket for more details.