我有一个方法,如下:
- (void) simpleMethod {
var = someValue;
}
Run Code Online (Sandbox Code Playgroud)
我想定义一个仅存在于该方法中的函数(我可以在python中执行此操作).我试着将它定义为普通的C函数,就像这样......
- (void) simpleMethod {
var = someValue;
int times1k(int theVar) {
return theVar * 1000;
}
ivar = times1k(var);
}
Run Code Online (Sandbox Code Playgroud)
但Xcode会抛出各种错误.是否可以在Objective-C中的方法中定义函数?如果是这样,怎么样?