0

Im brand new to Cocoa, and im struggling to find the answer and figure it out.

if I have a NSTextField how can I get the value (stringvalue) of that and save it in a predefined string variable, there after display it in the debug using NSLog()?

Thanks

Robert de Klerk
  • 624
  • 3
  • 12
  • 24

1 Answers1

3

Just use the stringValue method by NSTextField and save it to a NSString



@interface MyClass : NSObject
{
    NSTextField *textField;
}
-(IBAction)displayString:(id)sender;
@end


@implementation

-(IBAction)displayString:(id)sender
{
    NSString *string = [textField stringValue];
    NSLog (@"%@", string);
}

@end

Just connect the displayString method to the NSTextField and it should work.

TheAmateurProgrammer
  • 9,252
  • 8
  • 52
  • 71