OStack程序员社区-中国程序员成长平台

标题: ios - NSException 派生类或异常名称的列表? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 03:59
标题: ios - NSException 派生类或异常名称的列表?

我已经通过 Introduction to Exception Programming Topics for Cocoa .在 Throwing Exceptions 下,显示了一个异常名称:FileNotFoundException:

NSException *e = [NSException
    exceptionWithName"FileNotFoundException"
               reason"File Not Found on System"
             userInfo:nil];

@throw e;

但是,Predefined Exceptions页面列出了大约 10 个异常,FileNotFoundException 没有列出。

在哪里可以找到常见或预期的异常和名称列表?



Best Answer-推荐答案


这很奇怪,这些是我看到的在 NSExcpetion.h 中定义的唯一常量:

FOUNDATION_EXPORT NSString * const NSGenericException;
FOUNDATION_EXPORT NSString * const NSRangeException;
FOUNDATION_EXPORT NSString * const NSInvalidArgumentException;
FOUNDATION_EXPORT NSString * const NSInternalInconsistencyException;

FOUNDATION_EXPORT NSString * const NSMallocException;

FOUNDATION_EXPORT NSString * const NSObjectInaccessibleException;
FOUNDATION_EXPORT NSString * const NSObjectNotAvailableException;
FOUNDATION_EXPORT NSString * const NSDestinationInvalidException;

FOUNDATION_EXPORT NSString * const NSPortTimeoutException;
FOUNDATION_EXPORT NSString * const NSInvalidSendPortException;
FOUNDATION_EXPORT NSString * const NSInvalidReceivePortException;
FOUNDATION_EXPORT NSString * const NSPortSendException;
FOUNDATION_EXPORT NSString * const NSPortReceiveException;

FOUNDATION_EXPORT NSString * const NSOldStyleException;

关于ios - NSException 派生类或异常名称的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18564364/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4