开发者

iPhone SDK/General Xcode question

开发者 https://www.devze.com 2023-01-03 01:43 出处:网络
In the iPhone SDK, in my .n, I can say: -(IBOutlet) UITextField *MyNameIs; -(I开发者_开发知识库BOutlet) UILabel *DisplayMyNameIsHere;

In the iPhone SDK, in my .n, I can say:

-(IBOutlet) UITextField *MyNameIs;
-(I开发者_开发知识库BOutlet) UILabel *DisplayMyNameIsHere;

}

-(IBAction)PressButtonToDisplayYourName;

Then in my .m, I'll do:

-(IBAction)PressButtonToDisplayYourName {
     DisplayMyNameIsHere = MyNameIs.text;
}

But now how would I translate that to making a Mac application. If I wanted to display someones name from a textfield in a label? I have been trying to figure this out, but the ".text" extension only works in the iPhone SDK, not the Mac SDK. Someone please help! Thanks!


If you're referring to a Cocoa application, you could do the following in your .h file:

IBOutlet NSTextField *myLabel;

IBOutlet NSTextField *myTextField;

-(IBAction)displayName:(id)sender;

And then you could implement it in the .m file:

EDITED FOR COCOA:

-(IBAction)displayName:(id)sender{ [myLabel setStringValue:[myTextField stringValue]]; }

0

精彩评论

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