Question

I'm using a sudz-c generated SOAP framework, my service calls seem to work fine, but when I try doing anything with the data, iOS (emulator) crashes.

This is the service call...

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

For the handleToDoList: I am using the standard method provided in the examples, which successfully NSLogs my result.

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

From here, I get the log you see below.

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

When I attempt to NSLog the child count as seen below, or any of the other CXMLNode instance method for that matter, I get the following exception.

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

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

Not sure where to go from here. I've seen blogs such as this talking about issues with touchXML and namespaces, but it appears to me that I have a namespace.

Any ideas would be appreciated, when it comes to SOAP I'm noob class.

Was it helpful?

Solution

This is a common mistake; when logging integers you should use %i instead of %@, like this:

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

%@ is only for logging objects. If you try to log an integer as an object, you get a crash because it thinks it's a pointer to a random place in memory, and tries to call the description method on it.

Also, from the exception that you're getting, xmlResult is an NSDictionary (CFDictionary is the same thing), in which case the method you should be calling is count, not childCount:

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

OTHER TIPS

For printing count..

You should use '%d'

ex:

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top