Search code examples
objective-csudzc

sudzc how to use the returned object from ws call


The sudzc generated stub is:

(void)HandleSearchResult: (id) value { ...

The document indicates that "value" can be cast into (SDZSearchItemsByUpcResponse *). However that was not true.

In XCode, the type of "value" appears to be __NSCFDictionary.


Solution

  • __NSCFDictionary is a concrete subclass of either NSDictionary or NSMutableDictionary. Handle like so:

    -(void)handleSearchResult:(id)value {
        NSDictionary* dict = value;
        NSLog(@"value is: %@", dict);
        // Do what you want with your dictionary
    }
    

    I would skip SudzC and use CWXMLTranslator from https://github.com/jayway/CWFoundation. It allows you to ignore most of the cruft in SOAP XML responses, and translates directly to proper domain objects, not dictionaries and other placeholders.