0

I have a view where a user enters 3 sting fields. On the button press the fields are stored in an array. The button also changes the view.

The problem im having is when I get the strings from the array in the other view. The values that are being returned are the pervious values that have been entered.

I have added some lines to log what is going in and what is come out of the arrays. From the log I can see that the array is being called before it is set.

How to I get the button to run its action before it changes the view?

Here is my log:

2012-09-27 14:56:49.530 BeerDivider[1585:907] GetArray:(null) 2012-09-27 14:56:49.543 BeerDivider[1585:907] SetArray:( 3, will, Harry ) 

EDIT: Here is my code. http://pastebin.com/BX5gqp17

1
  • Are you transitioning to the other view using a segue? Can you move the code from your button into the prepareForSegue method? Commented Sep 27, 2012 at 13:59

1 Answer 1

1
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"yourSegue"]) { //do what you need } } 
Sign up to request clarification or add additional context in comments.

3 Comments

This is a good start. You may want to add some text around the code example to make it clear what you are trying to illustrate, and to explain how this can be connected to a segue from the storyboard.
Yeah I have only been working with object-c for about a week. not really sure how to implement this. Please could you explain a little bit more? Thanks
@Stas I actually love you! I have spent soo long trying to get this to work. I needed to give the segue and identifier and use your code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.