Get text from TextField

SunnyMan

Registered
Hi all, i need your help, i have simple project(cocoa app)

picture1drd.png


untitled.h:
Code:
#import <Cocoa/Cocoa.h>

@interface untitled : NSObject {
    IBOutlet id mylabel;
}
- (IBAction)ButtonClick:(id)sender;
@end

untitled.m:
Code:
#import "untitled.h"

@implementation untitled

- (IBAction)ButtonClick:(id)sender {
	
	[mylabel setStringValue:@"Test"];
}
@end

How I can get string value, from TextField. I click to the button([mylabel setStringValue:mad:"Test"]) and i need get value(my own value, not this static string "Test") from TextField and put in the Label(where "Test" right now)

Thx a lot.
 
If your new to Cocoa/C++ you might want to go a different route.
For example BASIC. In FutureBASIC you write your code and can use Carbon NIB windows. In REALbasic you design the interface and click on a button and put a little bit of code in the button to make it do something. FutureBASIC converts the BASIC code to Objective C; REALbasic compiles Universal Binary and soon will add Cocoa Support.
 
If your new to Cocoa/C++ you might want to go a different route.
For example BASIC. In FutureBASIC you write your code and can use Carbon NIB windows. In REALbasic you design the interface and click on a button and put a little bit of code in the button to make it do something. FutureBASIC converts the BASIC code to Objective C; REALbasic compiles Universal Binary and soon will add Cocoa Support.
 
Since you already know how to set up outlets and actions, this should be simple.

First, set up a new outlet (let's call it "myfield"), and connect it to the text field. Then just do something like this:
Code:
[mylabel setStringValue:[myfield stringValue]];
 
Back
Top