NSXMLParser * theParser = [[NSXMLParser alloc] initWithContentsOfURL: myStationURL];
the unit-tests hung.
After some exploration, I've found that NSURL resourceDataUsingCache: seems to hang during unit-test, but not when the Foundation Tool is executed via the Debug->Run Executable menu item.
Here's the pertinent code snippet:
- (id) fetch
{
NSLog([@"Fetching from URL " stringByAppendingString: [myStationURL absoluteString]]);
NSData * foo = [myStationURL resourceDataUsingCache: NO];
if (nil == foo) {
NSString * reasonPrefix = @"Error retrieving current observations from '";
NSString * reasonSuffix = @"'.";
NSString * reasonMsg = [reasonPrefix stringByAppendingString:
[[myStationURL absoluteString]
stringByAppendingString: reasonSuffix]];
NSException * exception = [NSException exceptionWithName:@"NWSStationFetchException"
reason:reasonMsg userInfo: nil];
@throw exception;
}
NSLog(@"Got data");
and the result of running the unit test via Build of my UnitTest target:
/bin/sh -c /Users/smb/Developer/Projects/NWSCurrentObs/build/NWSCurrentObs.build/Debug/UnitTest.build/Script-97276FE70E088C8800F0E701.sh
2008-06-18 18:15:30.945 NWSCurrentObs[5105] +[NSATSGlyphGenerator initialize] invocation. The class is deprecated.
Test Suite 'All tests' started at 2008-06-18 18:15:30 -0400
Test Suite '/Users/smb/Developer/Projects/NWSCurrentObs/build/Debug/UnitTest.octest(Tests)' started at 2008-06-18 18:15:30 -0400
Test Suite 'ORRNWSCurrentObsUnitTest' started at 2008-06-18 18:15:30 -0400
I had to click the "Stop Build" button to get the test un-hung.
Here's the result of Debug->Run Executable:
[Session started at 2008-06-18 18:39:51 -0400.]
2008-06-18 18:39:51.820 NWSCurrentObs[5147] Hello, World!
2008-06-18 18:39:52.678 NWSCurrentObs[5147] Got data
2008-06-18 18:39:52.709 NWSCurrentObs[5147] Created parser
2008-06-18 18:39:52.709 NWSCurrentObs[5147] Parsed XML
NWSCurrentObs has exited with status 0.
There's nothing in the console or system logs.
Any ideas on what's going on and how to work around it?
Best regards,
-Steve