Hi, I am using NSXMLParser with XML data from a share point server.
If i download more than ten rows of xml at a time it crashes at AppDelegate.h "EXC_BAD_ACCESS".... in the log it says...
"error while killing target (killing anyway): warning: error on line 2184 of "/SourceCache/gdb/gdb-1708/src/gdb/macosx/macosx-nat-inferior.c" in function "void macosx_kill_inferior_safe()": (os/kern) failure (0x5x)"
Also if i include any of the commented out attributes (see code), with even just one row of xml applied, it will also crash.
I can run to a break point just before the dealloc with 20+ rows (the most i have to test) and all the attributes included and I get NO crash.
When I run "Analyze" there are no leaks.
This is parse 6 in a process of 7 separate parses of xml lists. In the end I will need to parse at least 80 rows in this instance .. can someone tell me what i am doing to cause this?
Thanks.
I have included what code i think is relevant.. if you need more just ask.
Code:
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
//NSLog(@"DONE. Received Bytes: %d", [webData length]);
//NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
//NSLog(@"theXML: %@",theXML);
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
xmlParser = [[NSXMLParser alloc]initWithData:webData];
[xmlParser setDelegate: self];
[xmlParser parse];
[webData release];
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
[nodeContent appendString:[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElement = [elementName copy];
if ([elementName isEqualToString:@"z:row"]) {
currentTitle=[[NSString alloc]init];
currentTitle =[attributeDict valueForKey:@"ows_Title"];
currentDepartment=[[NSString alloc]init];
currentDepartment =[attributeDict valueForKey:@"ows_Department"];
// get rid of the stuff at the front
currentDepartment =[currentDepartment substringFromIndex:3];
currentScope=[[NSString alloc]init];
currentScope =[attributeDict valueForKey:@"ows_Scope"];
currentFormType=[[NSString alloc]init];
currentFormType =[attributeDict valueForKey:@"ows_Form_x0020_Type"];
currentSection=[[NSString alloc]init];
currentSection =[attributeDict valueForKey:@"ows_Section"];
// get rid of the stuff at the front
currentSection =[currentSection substringFromIndex:3];
currentVersion=[[NSString alloc]init];
currentVersion =[attributeDict valueForKey:@"ows_Version_x0020_Number"];
/*
currentResponsible=[[NSString alloc]init];
currentResponsible =[attributeDict valueForKey:@"ows_Responsible"];
currentStatus=[[NSString alloc]init];
currentStatus =[attributeDict valueForKey:@"ows_Status"];
currentFollowUp=[[NSString alloc]init];
currentFollowUp =[attributeDict valueForKey:@"ows_Follow_x002d_up_x0020_Required"];
*/
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"z:row"]) {
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc]init];
[tempDict setObject:currentTitle forKey: @"formTitle"];
[tempDict setObject:currentDepartment forKey: @"formDepartment"];
[tempDict setObject:currentScope forKey: @"formScope"];
[tempDict setObject:currentFormType forKey: @"formType"];
[tempDict setObject:currentSection forKey: @"formSection"];
[tempDict setObject:currentVersion forKey: @"formVersion"];
//[tempDict setObject:currentResponsible forKey: @"formVersion"];
//[tempDict setObject:currentStatus forKey: @"formVersion"];
//[tempDict setObject:currentFollowUp forKey: @"formVersion"];
NSString *tempFormName = [[NSString alloc] initWithFormat:@"%@",currentTitle];
[mDict setObject:tempDict forKey:tempFormName];
[currentTitle release];
[currentDepartment release];
[currentScope release];
[currentFormType release];
[currentSection release];
[currentVersion release];
//[currentResponsible release];
//[currentStatus release];
//[currentFollowUp release];
[tempDict release];
[tempFormName release];
}
}
- (void)parserDidEndDocument:(NSXMLParser *)parser {
//save FormTemplate Details in the Documents Directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documents = [paths objectAtIndex:0];
NSString *fullFileName = [NSString stringWithFormat:@"%@/FormData.plist",documents];
[mDict writeToFile:fullFileName atomically:NO];
mDict=nil;
//Retrieve File to see how it looks
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"FormData.plist"];
NSDictionary *rootDict = [NSDictionary dictionaryWithContentsOfFile:plistPath];
NSMutableString *tempString = [[NSMutableString alloc]init];
for (id key in rootDict) {
[tempString appendString:key];
[tempString appendString:@", "];
}
NSLog(@"FormData: (%d) %@", [rootDict count],tempString);
[tempString release];
//Pass to next Method
SyncUsers *syncUsers = [[SyncUsers alloc] init];
[syncUsers syncUserData];
[syncUsers release];
}
- (void)dealloc {
[accountData release];
[mDict release];
[super dealloc];
}
@end