Xcode NSString in textfield
I'm completely new to Xcode and Objective-C but I have succeeded in creating a btton and when the user 开发者_StackOverflowclicks this button a number is displayed in a textfield, but I can't seem to find a way to put text in there.
-(IBAction) button1pressed: (id) sender {
[field1 setIntValue:36];
}
-(IBAction) button1pressed: (id) sender {
[field1 setStringValue:@"some text"];
}
Method inherited from NSControl
, Documentation here: http://developer.apple.com/library/mac/documentation/cocoa/reference/ApplicationKit/Classes/NSControl_Class/Reference/Reference.html#//apple_ref/occ/instm/NSControl/setStringValue:
Make sure your properly making connections in xCode between the IB Text field (I assume your using IB since you're using IBAction) and the IBOutlet NSTextField *field1;
instance variable.
精彩评论