问题描述
大家好,
我一直在研究iPhone应用程序,该应用程序以以下格式解析XML:
<人>
< PERSON NAME ="KAREL" AGE ="23"/>
< PERSON NAME ="KEES" AGE ="23"/>
</PEOPLE>
紧接着,我创建了一个类PersonClass,同时具有变量Name和Age.
现在,在我正在读取XML的文件中,我设置了以下内容:
< pre lang ="c#">
#import"PeopleStruct.h"
@interface PeopleData:NSObject {
人* currentPerson;
NSMutableArray * allPeople;
NSXMLParser *解析器;
}
@property(只读,保留)NSMutableArray * allPeople;
-(id)readPeopleXML;
@end
</pre>
在PeopleData文件中,我放置了@Synthesize allPeople;
我正在读这样的人:
< pre lang ="c#"> ;-( void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURIqualifiedName:(NSString *)qName属性:(NSDictionary *)attributeDict
{
如果([elementName isEqualToString:@"PERSON"])
{
currentPerson = [PersonClass alloc];
currentPerson.name = [attributeDict objectForKey:@"NAME"];
currentPerson.age = [attributeDict objectForKey:@"AGE"];
[allPeople addObject:currentPerson];
currentPerson = nil;
}
}</pre>
但是,该应用程序由于以下原因而无法构建应用程序:
currentPerson = [PersonClass alloc];
并抛出错误:
体系结构i386的未定义符号:
"_OBJC_CLASS _ $ _ PersonClass",引用自: PeopleData.o中的objc-class-ref
ld:找不到体系结构i386的符号
clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
任何人都可以告诉我如何绕过此方法?
顺祝商祺,
拉斯
在此先感谢:)
Hi Everyone,
I''ve been working on an iPhone application which parses XML in the format of:
<PEOPLE>
<PERSON NAME="KAREL" AGE="23" />
<PERSON NAME="KEES" AGE="23" />
</PEOPLE>
Next to this, i''ve made a class PersonClass with both the variable Name and Age.
Now in the file where i''m reading the XML i''ve set the following:
<pre lang="c#">
#import "PeopleStruct.h"
@interface PeopleData: NSObject {
Person *currentPerson;
NSMutableArray *allPeople;
NSXMLParser *parser;
}
@property (readonly, retain) NSMutableArray *allPeople;
- (id)readPeopleXML;
@end
</pre>
In the PeopleData file i''ve put an @Synthesize allPeople;
And i''m reading the people like this:
<pre lang="c#">-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if ([elementName isEqualToString:@"PERSON"])
{
currentPerson = [PersonClass alloc];
currentPerson.name = [attributeDict objectForKey:@"NAME"];
currentPerson.age = [attributeDict objectForKey:@"AGE"];
[allPeople addObject:currentPerson ];
currentPerson = nil;
}
}</pre>
However, the app fails to build the application because of the line:
currentPerson = [PersonClass alloc];
And throws the error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_PersonClass", referenced from:
objc-class-ref in PeopleData.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Anyone who could tell me how to bypass this?
Yours Sincerely,
Lars
Thanks in advance :)
推荐答案
currentPerson = [[PersonClass alloc] init];
代替吗?
也许您错过了
instead ?
Or maybe you missed the
#import PersonClass.h
?
无论如何,我不确定自己在说什么.
?
Anyway, I''m not sure of what I''m saying.
这篇关于iPhone XML解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!