4 Replies
      Latest reply on Apr 2, 2019 6:12 AM by motivus
      motivus Level 1 Level 1 (0 points)

        I have this code in my ViewController.swift for invoking my REST API (via AWS API Gateway) and am attempting to print `result` to the console. Clearly, all I'm doing here is printing the address of the class object:

         

        @IBAction func userInvokeApi(_ sender: UIButton) {
          print("You clicked invoke api...")
          let client = SVTLambdaGateClient.default()
          client.calcGet(operand2: "3", _operator: "+", operand1: "5").continueWith{ (task: AWSTask?) -> AnyObject? in
               if let error = task?.error {
                    print("Error occurred: \(error)")
                    return nil
               }
        
               if let result = task?.result {
                    // Do something with result
                    print("The result is... \(result)")
               }
        
               return nil
           }
        }

         

        Here's what prints:

        You clicked invoke api... The result is...  <AmplifyRestApiTest.Empty: 0x600003309940>     {
        }

        Now, in the Variables view of the debug console this is what I see:

        > result = (RestApiTest.Empty) 0x600003309940
          > AWSCore.AWSModel (AWSModel)
            > baseAWSMTLModel@0 (AWSMTLModel)
              > NSObject
                isa = (Class) 0x600003309940

        Or, when I issue `(lldb) p result` in the debug console:

         

        (lldb) p result
        (RestApiTest.Empty) $R0 = 0x0000600003309940 {
          AWSCore.AWSModel = {
            baseAWSMTLModel@0 = {
              NSObject = {
                isa = 0x0000600003309940
              }
            }
          }
        }

         

        Can someone explain to me why I am not seeing the values?

         

        As some background, I'm using the AWS API Gateway-generated iOS Swift SDK to access my REST API from my iOS Client. I followed all of the tutorial instruction for using the SDK in my project. I know that I'm invoking the REST API successfully because I can see (via Cloudwatch logs) that it's returning the result to the Client.

        • Re: Using debugger to see contents of class object
          eskimo Apple Staff Apple Staff (11,505 points)

          Or, when I issue (lldb) po result in the debug console:

          [I’m going to presume you’re stopped on line 12 when you do that.]

          The example you included uses p result, not po.

          Can someone explain to me why I am not seeing the values?

          What values are you expecting to see here?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Using debugger to see contents of class object
              motivus Level 1 Level 1 (0 points)

              Thanks for your reply! I will correct my post so I refer to `p result` and not `po`.

               

              Whether I view `result` at the breakpoint or step in one statement, the values remain the same.

               

              I'm assuming that there are values present for `result` and that I just don't know how to get at them. As I explained, I know that my REST API is being successfully invoked. And I know that the correct result is being returned to the Client.

               

              Does this `result` definitely mean that there are no values returned?

               

              I have a fuller explication of my problem over in the Swift subreddit, here. And I am reading the Swift docs from "The Basics" on through. But I'm simultaneously hoping that someone can help me understand what's going wrong at the Client, since everything seems to be going right with invoking the REST API and API Gateway sending back the response.

                • Re: Using debugger to see contents of class object
                  eskimo Apple Staff Apple Staff (11,505 points)

                  I'm assuming that there are values present for result and that I just don't know how to get at them.

                  That sounds reasonable enough, but it’s not something I can help you with.  result is derived from task, which is of type AWSTask.  I’m not familiar with that type (it’s certainly not Apple type).

                  Presumably AWSTask comes from some AWS library, in which case you’re likely to have much luck asking this question via the support channel provided by that library.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"

                    • Re: Using debugger to see contents of class object
                      motivus Level 1 Level 1 (0 points)

                      Honestly, that assessment, direct from the code itself, from someone familiar with Swift, is super helpful and even reassuring. I realize it's all obvious, and it becomes more obvious with each passing day. I just need to know how to 'orient my brain' here so I can start learning and not go on any wild goose chases. Thank you!