1

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.

1
  • u want to print in the console? or in the testfield... Commented Jan 20, 2012 at 6:29

4 Answers 4

13

This will do

NSLog(@"%@", myArray);
Sign up to request clarification or add additional context in comments.

Comments

4
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];

}

Comments

0
button.title = [myArray objectatindex:index];

Comments

0
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

2 Comments

this is not the solution to the question,write this in comment and also I guess that would be by mistake.
ok..ok...just saying..i was also thinking how doesn't the program already show any error..NSLog will suffice as a solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.