Lefora Free Forum
login join
Loading
618 views

Pure Noob Here with a Pure Noob Question

Page 1
1–2
rookie - member
1 posts

Hey guys,
So I very recently started learning cocoa and am still grasping at straws with just about everything. I've made a Hello World app following a tutorial

I've got a .xib with a text box and a button, and my code:

HelloWorld.h:

#import <

@interface HelloController : NSObject {
IBOutlet NSTextField *words;
}
- (IBAction)sayHello:(id)sender;
@end

HelloWorld.m:

#import "HelloController.h"

@implementation HelloController
- (IBAction)sayHello:(id)sender{
[words setStringValue:@"Hello, World"];
[words setNeedsDisplay:YES];
}
@end

Pressing the button then updates the text box with "Hello World."

I was very excited when this compiled and ran without a flaw, so I wanted to extend it. Unfortunately this is where I ran in to trouble. I put in a ComboBox that would contain a few phrases. Selecting a phrase would change the text passed to the text box upon pushing the button.

Unfortunately, using the ComboBox apparently requires using NSNotification and NSNotificationCenter... and this is where I get lost. If anyone can help me out, suggest a few lines, explain just how those are used... anything would help me get back on track. Thanks for reading,

HolyJaw

rookie - member
2 posts


connect delegate of combo box to your controller object

You have to implement a delegate method

comboBoxSelectionDidChange

In this set the text to be displayed

Page 1
1–2

Locked Topic


You must be a member to post in this forum

Join Now!