Books

jueves, 27 de octubre de 2011

NSXML In iOS

When porting your code to iOS you will find that you are unable to import NSXMLDocument.h, NSXMLNode.h, etc.

 You have 2 options, the first option is to re write your code
 The second option is to fix your code so in iOS you are able to use same interfaces.

For fix in your code one way is to use KissXML library (http://code.google.com/p/kissxml/)
Add the library to your project (see KissXML documentation).
The next step is to make your code use the library when in iOS, to do that in the header where you are using NSXMLDocument, NSXMLElement or NSXMLNode you should ad:


#ifdef TARGET_OS_IPHONE
#include "KissXML/Private/DDXMLPrivate.h"
#define NSXMLDocument   DDXMLDocument
#define NSXMLElement    DDXMLElement
#define NSXMLNode       DDXMLNode
#define NSXMLNodePrettyPrint DDXMLNodePrettyPrint
#endif

 This code will rename the KissXML class names to the name you are already using.
as KissXML has the same interface as NSXML* classes all your code should work.

Note: KissXML is not complete yet, so in some cases you should make some work around to make things work.


No hay comentarios: