Below is code for a program that I am working on. The idea is that you input an array of strings in a first text field, using a standard button. In a second text field you either input which index of the array you want to display in a third text field, or you choose to display (in the third text field) the number of elements in the array. This is done using NSPopUpButton. I cannot get it to build-and-go, however. I think I am incorrectly using itemTitleAtIndex. Below is my code.
#import "firsttryarrayadam.h"
@implementation firsttryarrayadam
-(id)init
{
[super init];
myArray=[[NSMutableArray alloc]init];
return self;
}
-(IBAction)asmbutton1
NSButton*)sender;
{
myInputArray=[input1 stringValue];
[input1 setStringValue
""];
[myArray addObject:myInputArray];
}
-(void)awakeFromNib
{
NSPopUpButton*popupButton = [[[NSPopUpButton alloc] initTextCell
""] autorelease];
[popupButton setEditable:YES]; [popupButton setBordered:NO];
[popupButton addItemsWithTitles:[NSArray arrayWithObjects
"index", @"number", nil]];
}
-(IBAction)popupButton
NSPopUpButton*)sender;
{
if (itemTitleAtIndex
opupButton isEqual
"index")
{
myInt=([input2 intValue]-1);
[input2 setStringValue
""];
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
else if (itemTitleAtIndex
opupButton isEqual
"number")
{
[output setObjectValue:[count myArray]];
}
}
@end
There errors I get are the following--
1. itemTitleAtIndex undeclared
2. error prior to : -- in reference to
if (itemTitleAtIndex
opupButton isEqual
"index")
3. error before else.
Would appreciate any input. The awakeFromNib portion of the program I borrowed from a prior thread regarding NSPopUpButtonCell. I modified it, and probably am using it incorrectly. Thanks.
Adam
#import "firsttryarrayadam.h"
@implementation firsttryarrayadam
-(id)init
{
[super init];
myArray=[[NSMutableArray alloc]init];
return self;
}
-(IBAction)asmbutton1
{
myInputArray=[input1 stringValue];
[input1 setStringValue
[myArray addObject:myInputArray];
}
-(void)awakeFromNib
{
NSPopUpButton*popupButton = [[[NSPopUpButton alloc] initTextCell
[popupButton setEditable:YES]; [popupButton setBordered:NO];
[popupButton addItemsWithTitles:[NSArray arrayWithObjects
}
-(IBAction)popupButton
{
if (itemTitleAtIndex
{
myInt=([input2 intValue]-1);
[input2 setStringValue
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
else if (itemTitleAtIndex
{
[output setObjectValue:[count myArray]];
}
}
@end
There errors I get are the following--
1. itemTitleAtIndex undeclared
2. error prior to : -- in reference to
if (itemTitleAtIndex
3. error before else.
Would appreciate any input. The awakeFromNib portion of the program I borrowed from a prior thread regarding NSPopUpButtonCell. I modified it, and probably am using it incorrectly. Thanks.
Adam