本文介绍了iphone:尝试结束尝试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Objective-C中是否有任何方式可以查看是否可以执行某项任务而不会使应用程序崩溃?

Is there in objective-C any way to see if it is possible to do a certain task without risking crash the application?

其他语言(如javascript)

Other languages like javascript have

try
  {
  //Run some code here
  }
catch(err)
  {
  //Handle errors here
  }

是在Objective-C中有什么东西?
如果是这样,语法是什么?

is there something in Objective-C?If so, what is the syntax?

谢谢。

推荐答案

查看:

Cup *cup = [[Cup alloc] init];

@try {
    [cup fill];
}
@catch (NSException *exception) {
    NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
}
@finally {
    [cup release];
}






还值得拥有一个看:

这篇关于iphone:尝试结束尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:24