I am still learning Cocoa and Objective-C. I am trying to do an exorcise in the book I have (Cocoa Programming for Mac OS X 3rd Ed. By: Aaron Hillegass), and I can't figure it out.
I am supposed to make an application with an input text feild, a label, and a button. It's supposed to set the label the length of the text in the input box when you hit the button. I believe I have the app laid out correctly. However, I am not sure how to use the length method of the NSString class.
The buttons and such are linked (as far as I can tell, if there is something you want me to check I can). But how can I set the output label to length of the input textfield?
Thanks!
I am supposed to make an application with an input text feild, a label, and a button. It's supposed to set the label the length of the text in the input box when you hit the button. I believe I have the app laid out correctly. However, I am not sure how to use the length method of the NSString class.
Code:
@interface count : NSObject {
//input box
IBOutlet NSTextField *textInput;
//output label
IBOutlet NSTextField *textOutput;
}
- (IBAction)count:(id)sender;
@end
@implementation count
- (id)init
{
[super init];
NSLog(@"init");
return self;
}
- (IBAction)countid)sender
{
//This part is wrong, I know
[textOutput setStringValue:[textInput stringValue]];
NSLog(@"Counting...");
}
@end
The buttons and such are linked (as far as I can tell, if there is something you want me to check I can). But how can I set the output label to length of the input textfield?
Thanks!