- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
attributes:(NSDictionary *)attributeDict{
//currentElenet is NSString
currentElement = [elementName copy];
if ([elementName isEqualToString:@"struct"]) {
self.post = [[Question alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if ([currentElement isEqualToString:@"string"]) {
post.text = [NSString stringWithFormat:@"%@ %@", post.text, string];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"struct"]) {
[conversations addObject:post];
[post release];
post = nil;
}
}
//Question.m file
@synthesize text
-(id)init{
self = [super init];
if (self == nil) {
}
else {
//declared as retain in .h file
text = [[NSString alloc]initWithString:@""];
}
return self;
}
-(void)dealloc{
[super dealloc];
[title release];
}
ここでメモリが漏れていますか?私はNSXMLデリゲートメソッドを呼び出し、それは基本的にNSMutableArrayに "Question"のインスタンスを置きます。私は楽器をチェックし、それを解析中にメモリリークがあります。しかし、私は、なぜ...目的C、メモリリーク?