Question

I'm just getting the basics down for objective c. I want to create a textfield whose string is the same as the title of the dropbox cell I choose. I have:

- (IBAction)dropbox:(id)sender{
NSPopUpButtonCell *sampleCell = [sender selectedCell];
[self setWord:@"%@",sampleCell.title]; 

[sampleCell release];
}

where word is declared as

@property (readwrite, nonatomic, retain) IBOutlet NSTextField *word;
@synthesize word = _word;

apparently I'm not allowed to have the placeholder argument when using [self setWord:]. Can you point me in the right direction?

Was it helpful?

Solution

First of all, you haven't gained ownership of sampleCell so you should not be releasing it. This will trigger an exception. Also, you're setting an NSTextField to a string.

This is what i would do:

- (IBAction)dropbox:(id)sender{
NSPopUpButtonCell *sampleCell = [sender selectedCell];
[self.word setTextValue:sampleCell.title]; 
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top