views:

51

answers:

1

Hi,

I'm in a struggle. I have this app with two views. View1 empty. View2 with a textfield and an OK button. I want to accomplish the following:

  1. On View2 the user inserts the name for a button; its title. (the way user reaches view2 is not relevant. It could be with a button or a tabbar button on View1.)
  2. After pressing OK button, View2 is removed. View1 is now visible.
  3. View1, now, has on it a run-time created button with the title provided by the user.

I have tried, calling from view2 after pressing the OK button, the method on view1 that creates the button. Doesn't work. There's no error, but the button does not appear. I guess this it is not conforming to MVC, as I've been told by a forum's fellow colleague. He suggested outlets. But were? I thought of Notifications. I'm unsure it even makes any sense in this case.

Any help appreciated. Thank you.

A: 

It may be overkill for this situation but one way to communicate between ViewControllers is by using the delegate pattern, here's some info from Apple on delegates.

bmalicoat
Hi,after the reading, yes, delegates are probably the answer. I tried textFieldDidEndEditing delegate for a Label in View2 though, and it worked just fine. Imagine now a Label in View1. How can I use the very same textfield delegate passing View2 textfield content to a label in View1? Thanks.
BigJoke