开发者

Parsing XML not working, why?

开发者 https://www.devze.com 2022-12-16 08:25 出处:网络
- (void)parserDidStar开发者_开发百科tDocument:(NSXMLParser *)parser { nestedChannels = [ [ NSMutableArray alloc ] init ];
- (void)parserDidStar开发者_开发百科tDocument:(NSXMLParser *)parser
{
    nestedChannels = [ [ NSMutableArray alloc ] init ];
    ....
}

- (void)parser:(NSXMLParser *)parser didStartElement....
{
    Channel *channel = [ [ Channel alloc ] init ];
    [ nestedChannels addObject:channel ];
    ....
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string....
{
    Channel *channel = [ nestedChannels lastObject ];
    channel.thumbnail = string;
    ....
}

@interface Channel : NSObject {

NSMutableString *thumbnail;

}


@property (nonatomic, retain) NSMutableString *thumbnail;

Error: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFString thumbnail]: unrecognized selector sent to instance 0x381c350'

It's like is not able to recognize the type of the object. Am I missing something

**nestedChannels is a NSMutableArray*


Seems like this is causing the problem.

channel.thumbnail = string;

What type is thumbnail in channel and what mutators are available? To me it looks like it is trying to set string to thumbnail but there's no setter that accepts string on thumbnail. Is thumbnail NSString?


It's unclear what you're asking; are these different methods? Your code formatting is a little odd. One thing to note is that, if the second snippet is indeed a method (though there are no brackets), you need to append the data passed in, as it may not be a complete element:

if (channel.name == nil) channel.name = [NSMutableString string];
[channel.name appendString: string];
0

精彩评论

暂无评论...
验证码 换一张
取 消