Objective C 中的声明放在哪里
我有一个 file1.h file1.m file1.xib,xib 有一个空白屏幕,上面有一个标签。我有另一个文件,它执行一些任意计算,并将在计算循环时更新标签。我应该在 file1.h 或执行计算的文件中的哪里声明 UILabel * 值?
谢谢你开车到处走走。
I have a file1.h file1.m file1.xib the xib has a blank screen with a label on it. I have another file that does some arbitrary calculation and will update the label as the calculation loops. Where should I declare the UILabel * value in file1.h or the file that does the calculations?
Thank you drive around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该标签应声明为 IBOutlet,正如 Josh 在您的 .h 文件中所说的那样,并且是在 Interface Builder 中连接您的标签。
您还可以在 .h 文件中将标签定义为 @property 并将其合成到 .m 文件中,以便您可以使用 轻松访问“myLabel”。操作员。
现在,要使用计算更新标签,只需在 .h 文件中定义 updateLabel 函数并编写代码以在实现文件中实现更新,如下所示:
The label should be declared as an IBOutlet as Josh said in your .h file as above and yes connect your label in Interface Builder.
You can also define your label as @property in .h file and synthesize it in .m file so that you can easily access "myLabel" using . operator.
Now to update your label with your calculations, simply define the updateLabel function in .h file and write your code to implement update in the implementation file as below:
该标签应在 .h 文件中声明为
IBOutlet
:确保将此插座连接到 Interface Builder 中的标签。
The label should be declared as an
IBOutlet
in your .h file:Make sure you connect this outlet to your label in Interface Builder.