如何在 Objective C 中将自定义对象转换为 NSString?
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要解析 XML,并可以选择从中创建一个对象或 NSDictionary 表示形式。在文档中搜索
NSXML
或CFXML
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 forNSXML
orCFXML
APIs.To use an
EmployeeDetails
instance to represent a string in aCommonRequest
, 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).