0

我正在尝试使用 sudzc 生成的文件获取特定数据。我已经使用他们的示例代码来了解 cxmlnode* result = (cxmlnode*)value;

它给了我 nslog 的:.....

"描述" = "测试描述";

...

如何获取数据测试描述以放入变量中?


有谁知道它是否必须用json解析?格式不是 xml。我是新手,仍然有问题。

我通过使用 NSDictionary 弄清楚了:

if( [value isKindOfClass:[NSError class]] || [value isKindOfClass:[SoapFault class]] ) {

NSLog(@"%@", [value description]);
return;
}

// Verify we're a dictionary
if( ![value isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: Response not a dictionary");
return;
}

NSDictionary* dict = (NSDictionary*)value;
NSDictionary* resp = [dict objectForKey:@"UpdateQOHLookupItemResult"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: UpdateQOHLookupItemResult not a dictionary");
return;
}
dict = [resp objectForKey:@"firstTierKey"];
if( ( dict == nil ) || ![dict isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: Diffgram not a dictionary");
return;
}
resp = [dict objectForKey:@"secondTierKey"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {

NSLog(@"ERROR: NewDataSet not a dictionary");
return;
}
4

2 回答 2

0

你有没有尝试过

NSString *data = [yourDictionary objectForKey:@"description"]
于 2012-05-01T13:25:02.930 回答
0

在调试会话期间(在处理程序中设置断点)非常容易在所有输出窗口中输入:po result。然后它将显示返回的 XML!它不是 JSON,因为 SUDZC 使用的是 SOAP。我有一个使用 SUDZC 的 .Net 后端项目,并且运行良好。您需要调整 SUDZC 生成的代码以满足您的需求。最好的开始方法是在 SOAPRequest.m 文件中反序列化之前记录返回的 XML。在方法 connectionDidFinishLoading 中使用 NSLog。您可能还需要这个: http ://www.dailycode.info/Blog/post/2012/08/10/Sudzc-code-generator-is-missing-SoapDictionary.aspx

于 2013-01-10T14:13:42.987 回答