断点后如何在Xcode中查看此Swift类对象的内容?

时间:2019-03-30 00:06:45

标签: ios objective-c swift xcode aws-api-gateway

我是Xcode和Swift的新手(...和认真的Swift编程),希望有人能帮助我弄清楚如何查看/访问此类对象的值。

我的ViewController.swift中有此代码,用于调用REST API(通过AWS API Gateway),并尝试将result打印到控制台。显然,我在这里所做的只是打印类对象的地址:

@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
    }
}

打印内容如下:

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

(其中AmplifyRestApiTest是我的Xcode项目的名称。尽管我使用AWS Amplify构建该项目;主要是因为使用它时遇到了问题。)

我在Empty中确实有这个Empty.swift类,它是API Gateway生成的iOS Swift SDK的一部分:

import Foundation
import AWSCore

@objcMembers
public class Empty : AWSModel {
    public override static func jsonKeyPathsByPropertyKey() -> [AnyHashable : Any]!{
    var params:[AnyHashable : Any] = [:]`
        return params
    }
}

现在,当我在打印语句上设置断点时,这就是我所看到的:

https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/ enter image description here enter image description here

有人可以告诉我为什么我看不到与此对象有关的值吗?拆开此API响应的策略是什么?

我知道我正在成功调用REST API,因为我可以看到(通过Cloudwatch日志)它将结果返回给客户端。所以这篇文章只是我尝试访问相应对象的方法。

另一个细节:我使用的是API网关生成的iOS Swift SDK,并且在项目中使用了所有enter image description here来使用SDK。

2 个答案:

答案 0 :(得分:0)

我建议在这里浏览文档... https://cocoapods.org/pods/AWSCore#getting-started-with-swift

您导入了适当的标题吗?

希望这会为您指明正确的方向。

答案 1 :(得分:0)

使用lldb命令po打印对象。

(lldb) po @"lunar"
lunar
(lldb) p @"lunar"
(NSString *) $13 = 0x00007fdb9d0003b0 @"lunar"
相关问题