[apple]UI和class的连接

来源:互联网 发布:淘宝商品id批量导出 编辑:程序博客网 时间:2024/05/22 10:32

 An object has no way of sending a message to another object if it doesn't have a reference to the other object. 

 

We have now instantiated our MFAExampleClass class in Xcode into an object in our xib file. This will allow our code and our interface to communicate.

object instances themselves don't contain the code to perform the action, but the classes do.

 

To create the connections, press the Control key on you keyboard and use the mouse to drag from the "Set to 5"" button to the MFAExampleClass instance in the MainMenu.xib window (don't do it the other way around!). 

 

Now the button holds a reference to our MFAExampleClass object, and will send it the setTo5:message whenever it is pressed.

 

Generate Code: IB画好界面后,可以用xcode自动生成代码

原创粉丝点击