Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

medasmx

macrumors member
Original poster
Nov 9, 2008
89
0
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:mad:""];
[myArray addObject:myInputArray];
}

-(void)awakeFromNib
{
NSPopUpButton*popupButton = [[[NSPopUpButton alloc] initTextCell:mad:""] autorelease];
[popupButton setEditable:YES]; [popupButton setBordered:NO];
[popupButton addItemsWithTitles:[NSArray arrayWithObjects:mad:"index", @"number", nil]];
}

-(IBAction)popupButton:(NSPopUpButton*)sender;
{
if (itemTitleAtIndex:popupButton isEqual:mad:"index")
{
myInt=([input2 intValue]-1);
[input2 setStringValue:mad:""];
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
else if (itemTitleAtIndex:popupButton isEqual:mad:"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:popupButton isEqual:mad:"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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.