1

Here is my question:

I have two view controllers (identified as ViewController1 and ViewController2)

ViewController2 has a label that is populated with text in a string format from ViewController1

I would like to manipulate that text from ViewController2.

I this possible?

Basically, I have a label that posts random information from the string and I would like to refresh this string that posts on label.

Thank you so much.

Patel
  • 543
  • 4
  • 20
coolMed
  • 13
  • 3

4 Answers4

0

If ViewController1 pushes or present ViewController2:

To send a message from VC1 to VC2, just create a public method on VC2 and call it from VC1.

To send a message from VC2 to CV1, create a delegate on VC2 and implement it on VC1.

Antonio MG
  • 20,382
  • 3
  • 43
  • 62
0

Make a property in VC2 and put the string in the VC2.property at the time of pushing the VC2 from VC1.

Read about property and message passing

Dushyant Singh
  • 721
  • 4
  • 13
  • I've had no problem pushing VC2 from VC1. The issue is reloading that string in order to view a new information on the label? Am I missing something? – coolMed Oct 23 '13 at 10:11
  • @coolMed Never said you have problem in pushing view. Just told you to make a property in VC2 which you can access in VC1. Consider this tutorial http://devinsheaven.com/cocoa-tutorial-passing-messages-between-objects-notifications-delegates-and-target-action/ – Dushyant Singh Oct 23 '13 at 10:18
0

Refer my answer to a similiar question here (global variable in appDelegate) and here (properties)

Or you can use singleton

Community
  • 1
  • 1
Ramaraj T
  • 5,184
  • 4
  • 35
  • 68
0

You can adopt two option for it.

1) You can take a string property in VC2 and set it in VC1 when pushing VC2 OR

2) You can set that string in preferences in VC1 and use it from preferences in VC2

Bhavesh
  • 1,422
  • 1
  • 12
  • 31