开发者

Simply make a label say Hello World in Cocoa (Mac programming)

开发者 https://www.devze.com 2023-01-02 03:24 出处:网络
I\'m a total newbie to programming in cocoa for the mac so this question is probably easy.I have a window, and on that window I have a Label.

I'm a total newbie to programming in cocoa for the mac so this question is probably easy. I have a window, and on that window I have a Label.

I want to be able to update this label from my program with the current status or what's going on (eg. reading in file, parsing, etc.). My problem is that I don't know how to 开发者_StackOverflow中文版access the label and change it's text property. I tried "MyWindowName." hoping I would be able to reference the label from the Window. I don't even know what the labels name is, or even if it has a name.

How do I reference this label in my program to change it?


You probably need to go here and walk through some tutorials: http://www.cocoadevcentral.com/

A quick summary is that unlike other technologies, you don't access the controls directly (or shouldn't access them). Instead, you create outlets in a controller, which you then graphically connect to the controls and they update automagically. These tutorials will show you the way.


A label is just an NSTextField with different settings about editing/fonts, etc. Just make an outlet in your controller that connects to the view in Interface Builder, and you can change it like you would any other NSTextField.

0

精彩评论

暂无评论...
验证码 换一张
取 消