0

I've been attempting to create a delete request to remove a specific record from my custom objects using SFRestAPI. The code I've written so far is;

let deleteRequest = SFRestAPI.sharedInstance().performDelete(withObjectType: "Event__c", objectId: "Event-00003", fail: { (error :NSError!) -> Void in} as! SFRestFailBlock, complete: SFRestDictionaryResponseBlock)

However, this immediately throws error saying;

Cannot convert value of type 'SFRestDictionaryResponseBlock.Type' (aka '((Optional>) -> ()).Type') to expected argument type 'SFRestDictionaryResponseBlock' (aka '(Optional>) -> ()')

I've been able to get around this issue by casting the Fail block as NSError of type SFRestFailBlock this however doesn't seem to work for Complete Block in swift.

Salesforce SDK Type Definitions for Blocks are

public typealias SFRestFailBlock = (Error?) -> Swift.Void
public typealias SFRestDictionaryResponseBlock = ([AnyHashable : Any]?) -> Swift.Void

Any help will be appreciated, thanks in advance.

Matqo
  • 1
  • 2
  • I do not understand your code: `SFRestDictionaryResponseBlock`is a type, not a block value. However, include the definitions of `SFRestFailBlock` and `SFRestDictionaryResponseBlock`in your Q. Maybe the parameters are wrong. – Amin Negm-Awad Mar 05 '17 at 19:07
  • I've added the definitions as they are in the SDK. I know they're types I was just referencing that they represent blocks. Thanks – Matqo Mar 06 '17 at 00:25

1 Answers1

0

Long story short, the guys at SalesForce were able to give me quick solution for this. Turns out I've been using wrong syntax on one of my previous solutions. The working code is:

        SFRestAPI.sharedInstance().performDelete(
        withObjectType: "Event__c",
        objectId: "a000Y00000B3SGbQAN",
        fail: { (error: Error?) in
            self.log(.debug, msg: "Fail " + (error?.localizedDescription)!)
        }) { (response: [AnyHashable : Any]?) in
            self.log(.debug, msg: "Success" )
        };
Matqo
  • 1
  • 2