Does code in finally get run after a return in Objective-C?

前端 未结 5 1329
广开言路
广开言路 2020-12-20 12:14

Consider the following code:

@try {
  if (something.notvalid)
  {
    return;
  }
  // do something else
} @catch (NSException *ex) {
  // handle exception
}         


        
5条回答
  •  悲哀的现实
    2020-12-20 12:33

    With the RAI definition, Finally block will anyhow executed with that code scope, for particular resource.

    It has a close meaning with Object's ~Destructor. As same as an object's ~Destructor always executes, finally block also executes.

提交回复
热议问题