如何在 Objective C 中将自定义对象转换为 NSString?

发布于 2024-12-20 07:52:56 字数 495 浏览 0 评论 0原文

我正在使用 Objective C 代理对象(使用 wsdl2Objc 工具创建)来访问基于 SOAP 的 Web 服务。

它是一个基于 .Net 的 Web 服务。它返回 XML 数据。

用于访问该 Web 服务的基于 C# 的代理对象工作正常。

@interface EmployeeDetails{
    NSString name;
    NSString *empID;
    }
    @end

    @interface CommonRequest{
    NSString *sessionID;
    NSString *employeeDetails;
    }
    @end

在 C# 代理对象中,字段的类型是另一个自定义对象,而在 Objective C 中,类型是 NSString。

如何将自定义对象(EmployeeDetails 类型)转换为其 NSString 等效项(employeeDetails)?

I am using Objective C Proxy objects(which was created using wsdl2Objc tool) to access SOAP Based web services.

It is a .Net based Web service. It returns XML data.

The C# based Proxy Objects for accessing that web service is working properly.

@interface EmployeeDetails{
    NSString name;
    NSString *empID;
    }
    @end

    @interface CommonRequest{
    NSString *sessionID;
    NSString *employeeDetails;
    }
    @end

In C# proxy object the type of the field is another custom object whereas in Objective C the type is NSString.

How to convert Custom object(of type EmployeeDetails) into its NSString equivalent(employeeDetails)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻之岛 2024-12-27 07:52:56

您需要解析 XML,并可以选择从中创建一个对象或 NSDictionary 表示形式。在文档中搜索 NSXMLCFXML API。

要使用 EmployeeDetails 实例来表示 CommonRequest 中的字符串,您需要找出 API 期望的内容(您可以打印 C# CommonRequest > 要找出答案,或者更好地参考其实现以了解它如何构建字符串)。

You will need to parse the XML, and optionally create an object or NSDictionary representation from it. Search the documentation for NSXML or CFXML APIs.

To use an EmployeeDetails instance to represent a string in a CommonRequest, you will need to find out what the API expects (you can print the C# CommonRequest to find out, or better, refer to its implementation to see how it builds the string).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文