@try {
[cup fill];
} @catch ( CupWarningException *e ) {
printf( "%s: ", [[e name] cString] );
} @catch ( CupOverflowException *e ) {
printf( "%s: ", [[e name] cString] );
} @finally {
[cup print];
}
跟java差不多
本文展示了一种类似于Java的异常处理机制,通过@try、@catch和@finally等关键字来捕获并处理运行时可能出现的不同类型的异常,如CupWarningException和CupOverflowException。
@try {
[cup fill];
} @catch ( CupWarningException *e ) {
printf( "%s: ", [[e name] cString] );
} @catch ( CupOverflowException *e ) {
printf( "%s: ", [[e name] cString] );
} @finally {
[cup print];
}
跟java差不多

被折叠的 条评论
为什么被折叠?