Reputation: 11
iam working on one application.In that application,i declared the NSXmlParser object in viewdidload method.But where this object can be release.So please tell me which is the correct place for release that object.See my code
NSString *xmlFilePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"xml"];
NSData *data=[NSData dataWithContentsOfFile:xmlFilePath];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:data];
[xmlParser setDelegate:self];
[xmlParser setShouldProcessNamespaces:NO];
[xmlParser setShouldReportNamespacePrefixes:NO];
[xmlParser setShouldResolveExternalEntities:NO];
[xmlParser parse];
Upvotes: 0
Views: 63
Reputation: 2830
You can release it right after the parse method is called
[xmlParser parse];
[xmlParser release];
Note that parse
returns YES if successful and NO if not. So you might want to do some related operations before you release.
Upvotes: 1