I am resubmitting this with the code to my previous program, which worked. It had three text fields and two buttons. The first text field strings inputted strings to go into an array. The first button was pushed to input each member of the array. The second text field and button inputted an integer to query array members, by index. The output appeared in the third text field. Below is the 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];
}
-(IBAction)asmbutton2
NSButton*)sender;
{
myInt=([input2 intValue]-1);
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
@end
The only difference in the code that follows here is that I am adding a NSPopUpButton, so that you can do various things with the array, not just query by index. In the program below you are supposed to query either the index or the total number in the array. The idea with writing the second program was to figure out how to use NSPopUpButton.
When trying to build-and-go I get the errors below:
1. itemTitleAtIndex undeclared
2. error prior to : -- in reference to
if (itemTitleAtIndexopupButton isEqual
"index")
3. error before else.
#import "firsttryarrayadam.h"
@implementation firsttryarrayadam
-(id)init
{
[super init];
myArray=[[NSMutableArray alloc]init];
return self;
}
-(IBAction)asmbutton1NSButton*)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)popupButtonNSPopUpButton*)sender;
{
if (itemTitleAtIndexopupButton isEqual
"index")
{
myInt=([input2 intValue]-1);
[input2 setStringValue
""];
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
else if (itemTitleAtIndexopupButton isEqual
"number")
{
[output setObjectValue:[count myArray]];
}
}
@end
As previously stated, the awakeFromNib portion of the program I borrowed from a prior thread regarding NSPopUpButtonCell. I modified it, and probably am using it incorrectly. Thanks for any help.
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];
}
-(IBAction)asmbutton2
{
myInt=([input2 intValue]-1);
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
@end
The only difference in the code that follows here is that I am adding a NSPopUpButton, so that you can do various things with the array, not just query by index. In the program below you are supposed to query either the index or the total number in the array. The idea with writing the second program was to figure out how to use NSPopUpButton.
When trying to build-and-go I get the errors below:
1. itemTitleAtIndex undeclared
2. error prior to : -- in reference to
if (itemTitleAtIndexopupButton isEqual
3. error before else.
#import "firsttryarrayadam.h"
@implementation firsttryarrayadam
-(id)init
{
[super init];
myArray=[[NSMutableArray alloc]init];
return self;
}
-(IBAction)asmbutton1NSButton*)sender;
{
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)popupButtonNSPopUpButton*)sender;
{
if (itemTitleAtIndexopupButton isEqual
{
myInt=([input2 intValue]-1);
[input2 setStringValue
mySecondString=[myArray objectAtIndex:myInt];
[output setStringValue:mySecondString];
}
else if (itemTitleAtIndexopupButton isEqual
{
[output setObjectValue:[count myArray]];
}
}
@end
As previously stated, the awakeFromNib portion of the program I borrowed from a prior thread regarding NSPopUpButtonCell. I modified it, and probably am using it incorrectly. Thanks for any help.
Adam