Reputation: 701
I have a text box in my XIB named "txt" and a button named "next". Now on the click of next button I want to print values of myArray.
NSArray *myArray
myArray = [NSArray arrayWithObjects:@"1",@"3",@"5",@"45",@"67",nil];
can anyone help me with this.
Upvotes: 1
Views: 19195
Reputation: 2297
NSArray *myArray = [NSArray arrayWithObjects:@"1",@"3",@"5",@"45",@"67",nil];
-(IBAction)nextAction:(id)sender{
NSString *currentObj = txt.text;
int index = -1;
if(currentObj != nil&&[myArray containsObject:currentObj]){
index = [myArray indexOfObject:currentObj];
}
index++;
if(index<myArray.count)
txt.text = [myArray objectAtIndex:index];
}
Upvotes: 4
Reputation: 21805
NSArray *myArray myArray = [NSArray arrayWithObjects:@"1",@"3",@"5",@"45",@"67",nil];
change it to
NSArray *myArray = [NSArray arrayWithObjects:@"1",@"3",@"5",@"45",@"67",nil];
Otherwise you are doomed: D
Upvotes: 0