Basically, imagine this. i have an iPad , a Windows computer with apache http server which is hosting an xml file, and a wifi network that connects them both together
The xml parser im using is NSXMLParser
in my - (void)parseXMLFileAtURL method this is my code
NSError * error;
NSURLResponse * response;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@/UserBedData.xml",[appDelegate.hostipadd objectAtIndex:0]]] cachePolicy :NSURLRequestReloadIgnoringCacheData timeoutInterval:6.0];
[request setHTTPMethod:@"GET"];
NSData * responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error] ;
xmlParser = [[[NSXMLParser alloc] initWithData:responseData] autorelease];
[xmlParser setDelegate:self];
// Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
[xmlParser setShouldProcessNamespaces:NO];
[xmlParser setShouldReportNamespacePrefixes:NO];
[xmlParser setShouldResolveExternalEntities:NO];
[xmlParser parse];
If i have very little data in the xml file (which is on the windows computer) the parsing works fine and i would get the data and store them etc. After Parsing , i would request for another file which is a .php file that would when upon requested, delete('unlink') the xml file. Sort of for data consistancy. The method goes like this.
- (void)parserDidEndDocument:(NSXMLParser *)parser
NSError * error;
NSURLResponse * response;
//HTTPREQUEST to delete send a GET request to the server to a PHP file with pw = md5hash of a password. This is to delete the XML file
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@/delete.php",[appDelegate.hostipadd objectAtIndex:0]]] cachePolicy :NSURLRequestReloadIgnoringCacheData timeoutInterval:5.0];
NSData * responseData = [[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error] autorelease] ;}
now when it successfuly parses it, i can see on the PC that the XMLFile has been deleted. But here comes the problem now, when i have several hundreds of records in the XMLFile, im thinking that it takes too long to parses the data and crashes for whatever reason. The Error log is below. Im sure that the error occurs WHILE parsing because the XMLFile was NOT deleted. This means that the parserDidEndDocument method was not invoked.
So now i have no idea on how i should solve this . any ideas would be much appreciated and helpful. Thanks for reading guys
Date/Time: 2010-08-20 13:40:30.047 +0800
OS Version: iPhone OS 3.2.1 (7B405)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x000790a0 __kill + 8
1 libSystem.B.dylib 0x00079090 kill + 4
2 libSystem.B.dylib 0x00079082 raise + 10
3 libSystem.B.dylib 0x0008d20a abort + 50
4 libstdc++.6.dylib 0x00044a1c __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x000057c4 _objc_terminate + 104
6 libstdc++.6.dylib 0x00042dee __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x00042e42 std::terminate() + 10
8 libstdc++.6.dylib 0x00042f12 __cxa_throw + 78
9 libobjc.A.dylib 0x000046a4 objc_exception_throw + 64
10 CoreFoundation 0x00090c6e +[NSException raise:format:arguments:] + 74
11 CoreFoundation 0x00090d38 +[NSException raise:format:] + 28
12 UIKit 0x0010327a -[UIViewController _loadViewFromNibNamed:bundle:] + 178
13 UIKit 0x0006317a -[UIViewController loadView] + 74
14 UIKit 0x000693f2 -[UITableViewController loadView] + 46
15 UIKit 0x0005b2c0 -[UIViewController view] + 24
16 MedicalBed 0x0000ce7e -[SelectionScreen btnRefresh:] (SelectionScreen.m:188)
17 CoreFoundation 0x00025166 -[NSObject performSelector:withObject:withObject:] + 18
18 UIKit 0x000550ce -[UIApplication sendAction:to:from:forEvent:] + 78
19 UIKit 0x0005506e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
20 UIKit 0x00055040 -[UIControl sendAction:to:forEvent:] + 32
21 UIKit 0x00054d92 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 350
22 UIKit 0x000553e0 -[UIControl touchesEnded:withEvent:] + 336
23 UIKit 0x00053db6 -[UIWindow _sendTouchesForEvent:] + 322
24 UIKit 0x000536fe -[UIWindow sendEvent:] + 74
25 UIKit 0x0004f320 -[UIApplication sendEvent:] + 260
26 UIKit 0x0004ec8c _UIApplicationHandleEvent + 4772
27 GraphicsServices 0x00003b2c PurpleEventCallback + 660
28 CoreFoundation 0x00022d96 CFRunLoopRunSpecific + 2214
29 CoreFoundation 0x000224da CFRunLoopRunInMode + 42
30 GraphicsServices 0x000030d4 GSEventRunModal + 108
31 GraphicsServices 0x00003180 GSEventRun + 56
32 UIKit 0x0000342a -[UIApplication _run] + 374
33 UIKit 0x00001954 UIApplicationMain + 636
34 MedicalBed 0x0000219c main (main.m:14)
35 MedicalBed 0x00002150 start + 32
Thread 1:
0 libSystem.B.dylib 0x00001668 mach_msg_trap + 20
1 libSystem.B.dylib 0x00003734 mach_msg + 44
2 CoreFoundation 0x0002296e CFRunLoopRunSpecific + 1150
3 CoreFoundation 0x000224da CFRunLoopRunInMode + 42
4 WebCore 0x0000268a RunWebThread(void*) + 286
5 libSystem.B.dylib 0x0007a786 _pthread_start + 242
6 libSystem.B.dylib 0x00070070 thread_start + 0
Thread 2:
0 libSystem.B.dylib 0x00001668 mach_msg_trap + 20
1 libSystem.B.dylib 0x00003734 mach_msg + 44
2 CoreFoundation 0x0002296e CFRunLoopRunSpecific + 1150
3 CoreFoundation 0x000224da CFRunLoopRunInMode + 42
4 Foundation 0x00017a4c +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 164
5 Foundation 0x00010bca -[NSThread main] + 38
6 Foundation 0x0007ccf8 __NSThread__main__ + 896
7 libSystem.B.dylib 0x0007a786 _pthread_start + 242
8 libSystem.B.dylib 0x00070070 thread_start + 0
Thread 3:
0 libSystem.B.dylib 0x00025968 select$DARWIN_EXTSN + 20
1 CoreFoundation 0x00072d7c __CFSocketManager + 552
2 libSystem.B.dylib 0x0007a786 _pthread_start + 242
3 libSystem.B.dylib 0x00070070 thread_start + 0
Thread 0 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x381ac6d0
r4: 0x00000006 r5: 0x087411cc r6: 0x2fffe910 r7: 0x2fffe920
r8: 0x38029708 r9: 0x00000065 r10: 0x00000000 r11: 0x30ed3644
ip: 0x00000025 sp: 0x2fffe920 lr: 0x3167c097 pc: 0x3167c0a0
cpsr: 0x000f0010