0

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?

Nth.gol
  • 746
  • 9
  • 20

1 Answers1

3

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]; 
}
Arlen Anderson
  • 2,486
  • 2
  • 25
  • 36
  • excellent. thats the correct syntax, i needed no hardcoded string+placeholder since sampleCell.title is a string. and yes I guess because i never alloced I don't release. thank you – Nth.gol Jun 22 '12 at 17:09