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, 开发者_如何学Gothere after display it in the debug using NSLog()?
Thanks
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.
精彩评论