iOS Swift Read Request


I was wondering if there were any resources available to demonstrate how to conduct a EXORpcReadRequest for iOS using Swift? Though I’ve worked with the API before on other platforms, I am super new to iOS as well so I am trying to understand this process without a very strong understanding of Swift/Objective C.

I have imported the EXORpc cocoapod appropriately and I was able to accomplish a write command to a specific RID using an example in the forum, but when I tried to port this over to a read command, I wasn’t sure where the data was once I completed the read command. I would have presumed it was available in the callback but I’ve been going through the EXO files and can’t find any reference to a data object.

Below is my lousy code. I’d love some input on what additional step needs to be accomplished in order to access the JSON data.

    let questionRID = EXORpcResourceID(byRID: "RID")
    let sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration()
    let domain = NSURL(string: "")
    let rpc = EXORpc(domain: domain, sessionConfiguration: sessionConfig)
    let authKey = EXORpcAuthKey(CIK: "CIK")

    var req = EXORpcReadRequest.readWithRID(questionRID, complete: {_,_ in
            print("Read Request Created")
    rpc!.doRPCwithAuth(authKey!, requests: [req], complete: { (error: NSError?) -> Void in
        if ((error) != nil){

I’m slowly piecing together my iOS knowledge together so if there are any very apparent voids of basic knowledge, recommendations on where I should focus my efforts would be appreciated as well.

Thanks much!


Hi @boland -

Thanks for posting! I haven’t programmed much in Swift before and I have not yet used that library. Let me see if I can find someone who knows, or get educated about it myself.

Just out of curiosity, what happens if you try to print the req variable?



Hey Martin,

When I print the req variable I get:

<EXORpcReadRequest: 0x15f61d280, {
    arguments =     (
            limit = 1;
            selection = all;
            sort = desc;
    procedure = read;

My impression is that the EXORpcReadRequest handles the details of the read request itself and the EXORpc object conducts the communication based on the requests that it has been provided. But I’m just not sure where the data is put once the requests have been processed.

Thanks for your help!



I think I have figured it out. I declared an NSArray() object and then passed this into the callback method in the declaration of the EXORpcReadRequest. Then when the callback is called, the data is available and can be read. I then very clunkily, inefficiently and presumably incorrectly was able to parse out the contents of the raw data to get the value that I requested. I certainly need some work to understand how to properly deal with the data, but this seemed to work fine for now.

    var readResult = NSArray()
    var req = EXORpcReadRequest.readWithRID(questionRID, complete: { (readResult, error: NSError?) in
        var rawArray = String(readResult!).componentsSeparatedByString(":")
        var question: String = rawArray[5]
        question = String(question.characters.dropLast())
        question = String(question.characters.dropLast())
        self.questionLabel.text = question
    rpc!.doRPCwithAuth(authKey!, requests: [req], complete: { (error: NSError?) -> Void in
        if ((error) != nil){



Awesome! I am glad to hear that you were able to figure it out.

Thanks for posting your solution back,