I’m trying to create a Cocoa Objective-C program on my Snow Leopard MacBook running Xcode 4.2. Here/s what I want to do.
I have a textbox, a wrapping label, and a button. When you enter your name in the text box the wrapping label displays, "Have a merry merry christmas 'the name entered in the textbox'"
// AppDelegate.h
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
IBOutlet id inputTextField;
IBOutlet id outputTextField;
}
@property (assign) IBOutlet NSWindow *window;
- (IBAction)pressMeButton:(id)sender;
@end
// AppDelegate.m
#import "AppDelegate.h"
@implementation AppDelegate
//Use the pressMeButton IBAction to tell the inputTextField to display on the outputLabelField
- (IBAction)pressMeButton:(id)sender;
{
char inputString = [inputTextField charValue];
char outputString = [outputTextField charValue:(@"Have a merry merry Christmas, %@", inputString)];
[outputTextField outputString];
}
@end
I tried NSString, but I’m not sure what I’m doing wrong here.
You’re close, but far at the same time. It doesn’t make any sense to store a sequence of characters in a char type, which is for single char. Also, it doesn’t make sense to call a message which is actually a local variable. Anyway, here’s some code to help you.
Be sure to read the introductory docs, and the StackOverflow faq to get an idea of how to ask questions in the expected format.