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
I took a lot of this example from Hillegass "speakline". What I wrote has three textboxes and two buttons. The idea is to input into the first box, names (or strings), to go into an array. In the second box you input the integer whose array element you are trying to see. I got the program to run, but it stops at the second input (that is, it allows you to input the names, but when you put the integer in it stops). Below is my code.

Code:
#import <Cocoa/Cocoa.h>


@interface firsttryarrayadam : NSObject {
IBOutlet NSTextField*input1;
IBOutlet NSTextField*input2;
IBOutlet NSTextField*output;
NSMutableArray*myArray;
NSString*myInputArray;
NSString*mySecondString;
NSNumber*myInt;
}
-(IBAction)asmbutton1:(NSButton*)sender;
-(IBAction)asmbutton2:(NSButton*)sender;

@end

#import "firsttryarrayadam.h"


@implementation firsttryarrayadam


-(id)init
{
[super init];
myArray=[[NSMutableArray alloc]init];
return self;
}
-(IBAction)asmbutton1:(NSButton*)sender;
{
myInputArray=[input1 stringValue];
[myArray addObject:myInputArray];
}

-(IBAction)asmbutton2:(NSButton*)sender;
{
myInt=[input2 intValue];
mySecondString=[myArray objectAtIndex:myInt];
[output mySecondString];
}
@end

The error that comes out is the following --
2008-12-06 21:06:49.106 firsttryarray[260:10b] *** -[NSTextField mySecondString]: unrecognized selector sent to instance 0x127e70

Thanks.

Adam
 
It looks like you're trying to send a 'mySecondString' method to your 'output' NSTextField:

[output mySecondString];

Do you want to print the 'mySecondString' string to your 'output' NSTextField?

[output setStringValue: mySecondString];

?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.