iPhone - 将 NSError 处理到一个范围内
Posted
技术标签:
【中文标题】iPhone - 将 NSError 处理到一个范围内【英文标题】:iPhone - Handling NSError into a scope 【发布时间】:2011-07-16 14:27:11 【问题描述】:我正在尝试处理错误,但我发现很难知道可以返回给我什么样的错误。 例如,我从地图视图操作中调用了这个委托方法:
- (void) reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error;
我如何知道通过这种方法可以向我发送什么样的错误? 我不想处理整个错误目录... :-)
【问题讨论】:
【参考方案1】:MKReverseGeocoder.h 说:
// There are at least two types of errors:
// - Errors sent up from the underlying connection (temporary condition)
// - Result not found errors (permanent condition). The result not found errors
// will have the domain MKErrorDomain and the code MKErrorPlacemarkNotFound
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error;
猜你应该在提问之前阅读文档和标题。
【讨论】:
谢谢,但我没有找到您指向文档的内容:developer.apple.com/library/ios/#documentation/MapKit/Reference/… 我不应该阅读标题来找到我应该处理的内容。没有文档吗?如果方法头没有给我这些提示,我该怎么办?而且这些行并没有准确说明会给出什么错误。必须了解 MKErrorCode 与 MKErrorDomain 相关联。不是微不足道的。以上是关于iPhone - 将 NSError 处理到一个范围内的主要内容,如果未能解决你的问题,请参考以下文章