开发者

Xcode NSString in textfield

开发者 https://www.devze.com 2023-02-11 23:35 出处:网络
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 t

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.

0

精彩评论

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