【问题标题】:SOAP usage in iOS with touchXMLiOS 中的 SOAP 使用与 touchXML
【发布时间】:2012-02-02 15:09:06
【问题描述】:

我正在使用 sudz-c 生成的 SOAP 框架,我的服务调用似乎工作正常,但是当我尝试对数据执行任何操作时,iOS(模拟器)崩溃。

这是服务调用...

[service hentOpgaveliste:self action:@selector(handleToDoList:) userid:userNameTxt.text pdaid:[pdaIdTxt.text intValue]];

对于handleToDoList:我正在使用示例中提供的标准方法,它成功地对我的结果进行NSLogs。

....
CXMLNode *xmlResult = (CXMLNode*)value;
NSLog(@"HentToDo: %@", [xmlResult description]);
....

从这里,我得到你在下面看到的日志。

{
hentOpgavelisteResult =     {
    diffgram = "<null>";
    schema =         {
        element =             {
            complexType =                 {
                choice =                     {
                    element =                         {
                        complexType =                             {
                            sequence =                                 {
                                element = "<null>";
                            };
                        };
                    };
                };
            };
        };
    };
};

当我尝试 NSLog 如下所示的子计数或任何其他 CXMLNode 实例方法时,我得到以下异常。

....
NSLog(@"Children %@", [xmlResult childCount]);
....

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary childCount]: unrecognized selector sent to instance

不知道从这里去哪里。我看到博客 such as this 谈论有关 touchXML 和命名空间的问题,但在我看来,我有一个命名空间。

任何想法都将不胜感激,当谈到 SOAP 时,我是菜鸟类。

【问题讨论】:

标签: ios soap xsd touchxml


【解决方案1】:

这是一个常见的错误;记录整数时应该使用 %i 而不是 %@,如下所示:

NSLog(@"Children %i", [xmlResult childCount]);

%@ 仅用于记录对象。如果您尝试将整数记录为对象,则会发生崩溃,因为它认为它是指向内存中随机位置的指针,并尝试对其调用 description 方法。

另外,从你得到的异常来看,xmlResult 是一个 NSDictionary(CFDictionary 是一样的),在这种情况下你应该调用的方法是 count,而不是 childCount:

NSLog(@"Children %i", [xmlResult count]);

【讨论】:

  • childCount 返回 NSUInteger。我还是试了一下,同样的例外。
  • NSUInteger 对于 NSLog 来说是同一个整数,但无论如何我已经用你需要做的另一个修复更新了我的答案。
  • 将返回的对象视为 NSDictionary 让我有所收获,谢谢! (我会让你回答,但目前不能)
【解决方案2】:

用于打印计数..

你应该使用'%d'

例如:

NSLog(@"Children count = %d", [xmlResult childCount]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 2011-07-17
    • 2013-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-06
    相关资源
    最近更新 更多