当然,您可以使用 @try
-@catch
-@finally
街区,带有 @catch
省略。
MyConnection * connection = [ConnectionPool ConnectionWithDetails: @"host/server/port/etc"];
@try {
[connection doSomething];
}
@finally {
[ConnectionPool ReleaseConnection: connection];
}
无论您如何退出 @try
块, @finally
块将运行。