This objective C method is supposed to return an IBAction. Why is there no return statement?
我正在学习目标C和IOS开发。我想我掌握了方法语法。目标C中的方法语法
如果我理解正确,这个名为reset的实例方法应该返回IBaction对象。但它似乎只是在设置实例变量(这些变量是具有这些名称的UI文本字段)。为什么它没有返回IBaction对象的返回语句?
1 2 3 4 5 | - (IBAction)reset { //why does it not have a return statement? fahrenheit.text = @"32"; celsius.text = @"0"; kelvin.text = @"-273.15"; } |
我习惯于.NET代码,它看起来像这样(将其放入非NET人员的伪代码中):
1 2 3 4 5 6 | public function reset () returns IBAction me.fahrenheit.text ="32"; me.celsius.text ="0" me.kelvin.text ="-273.15" return new IBAction //I would expect something like this in obj C, based on my experience with .NET languages end function |
IBaction被typedef'd void。Xcode使用它作为提示,该方法可用于接口生成器中的"连接"。