我在我的应用程序中有一个简单的isEqualToString测试,出于某种原因,它始终采用if语句的错误路径,即使控制台显示它应该采用真实路径。iPhone/iOS isEqualToString总是返回false
下面是是有问题的代码:
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"Program requestFailed with error '%@' and reason '%@'", [error localizedDescription], [error localizedFailureReason]);
NSString *errorMessage = [NSString stringWithFormat:@"%@",[error localizedDescription]];
if ([[error localizedFailureReason] isEqualToString:@"(null)"])
{
}
else
{
errorMessage = [errorMessage stringByAppendingFormat:@"\nReason: %@", [error localizedFailureReason]];
}
[Utils msgBox:@"Error with Data Download" message:errorMessage];
}
并在控制台:
2011-04-15 14:27:07.341 Program[79087:207] Program requestFailed with error 'The request timed out' and reason '(null)'
2011-04-15 14:27:07.341 Program[79087:207] Displaying a message box with title 'Error with Data Download' and message 'The request timed out
Reason: (null)'
在我的Utils类MSGBOX方法输出的标题和消息发送到所述控制台,它是第二行来自哪里。
我一直在寻找这一段时间,答案必须如此简单以至于它不会注意到。有什么建议么? (我试图修剪空白[错误localizedDescription],无济于事。)我在最新的4.3 iOS SDK。