我的程序中使用GData xmlsupport出错了

时间:2010-05-28 05:20:36

标签: iphone gdata-api

我是新来的,我不知道如何使用这个......这是我的代码:

NSString *strParse=@"url";
NSURL *urlParse=[NSURL URLWithString:strParse];
NSString *content=[[NSString alloc] initWithContentsOfURL:urlParse];
NSError *error;
GDataXMLDocument *document=[[GDataXMLDocument alloc] initWithXMLString:content options:0 error:&error];

---------------------- XML -----

<?xml version="1.0" encoding="UTF-8"?>
<root>
<head>
<version>20100514103110</version>
</head>
<channels>
<channel>
<id>1</id>
<name>
<![CDATA[]]>
</name>
<uuid>
<![CDATA[21001]]>
</uuid>
<site_url>
<![CDATA[http://]]>
</site_url>
<pics>
<url>
<![CDATA[/21001/cms_images/channel/2010-01/21/channel_51224251664216081527429.png]]>
</url>
<url>
<![CDATA[/21001/cms_images/channel/2010-01/21/channel_82864703356323359638124.png]]>
</url>
<url>
<![CDATA[/21001/cms_images/channel/2008-07/04/channel_67535050807177704592393.swf]]>
</url>
<url>
<![CDATA[]]>
</url>
<url>
<![CDATA[]]>
</url>
</pics>
<linkurls>
<url>
<![CDATA[]]>
</url>
<url>
<![CDATA[]]>
</url>
<url>
<![CDATA[]]>
</url>
</linkurls>
<description>
<![CDATA[]]>
</description>
<provider>
<![CDATA[]]>
</provider>
<attr>3</attr>
<props>
<prop1>
<![CDATA[21001/movie_shell.swf]]>
</prop1>
<prop2>
<![CDATA[]]>
</prop2>
<prop3>
<![CDATA[]]>
</prop3>
<prop4>
<![CDATA[]]>
</prop4>
<prop5>
<![CDATA[]]>
</prop5>
</props>
</channel>
</channels>
</root>

----------错误如下---------------

 Ld build/Debug-iphonesimulator/newParser.app/newParser normal i386
    cd /Users/apple/Desktop/newParser
    setenv MACOSX_DEPLOYMENT_TARGET 10.5
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk -L/Users/apple/Desktop/newParser/build/Debug-iphonesimulator -F/Users/apple/Desktop/newParser/build/Debug-iphonesimulator -filelist /Users/apple/Desktop/newParser/build/newParser.build/Debug-iphonesimulator/newParser.build/Objects-normal/i386/newParser.LinkFileList -mmacosx-version-min=10.5 -lxml2 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/apple/Desktop/newParser/build/Debug-iphonesimulator/newParser.app/newParser

    Undefined symbols:
      "_kGDataXMLXPathDefaultNamespacePrefix", referenced from:
          _kGDataXMLXPathDefaultNamespacePrefix$non_lazy_ptr in GDataXMLNode.o
         (maybe you meant: _kGDataXMLXPathDefaultNamespacePrefix$non_lazy_ptr)
    ld: symbol(s) not found
    collect2: ld returned 1 exit status

2 个答案:

答案 0 :(得分:11)

从预编译的头文件(以及其中包含的.h文件)中删除#import“GDataXMLNode.h”,并仅在需要的实现文件中添加它。

答案 1 :(得分:8)

或者,您可以只定义符号。改变:

_EXTERN const char* kGDataXMLXPathDefaultNamespacePrefix _INITIALIZE_AS("_def_ns");

类似于:

#define kGDataXMLXPathDefaultNamespacePrefix ("_def_ns");

他们在原始语句中使用了一些预处理器技巧,但据我所知,这不会导致任何问题,并且允许您在.pch中导入GDataXMLNode.h,如果你这样做非常方便经常使用它 - 就像我一样!

当然,请确保您测试此功能也适合您