// NSCocoaErrorDomain
-(void) test1_domain_error
{
[self addLog: [NSString stringWithFormat:@"%s %d", __FUNCTION__, __LINE__]];
NSError *error = nil;
NSString *urlString = @"";
NSURL *url = [NSURL URLWithString: urlString];
NSString *webResponse = [NSString stringWithContentsOfURL: url encoding: NSUTF8StringEncoding error: &error];
[self addLog: [NSString stringWithFormat:@"Accessing %@", urlString]];
if(nil != error)
{
[self addLog: [NSString stringWithFormat: @"Error code = %d, %@", [error code], [error domain]]];
}
else
{
[self addLog: [NSString stringWithFormat: @"Access %@ OK, webResponse = %@", urlString, webResponse]];
}
}
阅读(996) | 评论(0) | 转发(0) |