Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two ways for achieving it. 1.Make a singleton class for shared data(in your case that string which you want to pass from one ViewController to another).</p> <p>2.Declare shared data in appDelegate class.(you should use second mathod because you just want string to be shared).</p> <p>In your appDelegate.h declare your string</p> <pre><code>@property(retain,nonatomic) NSString *YourString; </code></pre> <p>now in your second viewController assign the value you want.</p> <pre><code>AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; appdelegate.YourString = @"Your VAlue"; </code></pre> <p>Now access the same string from first ViewController.</p> <pre><code> AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; self.yourLable.text = appdelegate.YourString; </code></pre> <p><strong>I couldn't attache source code here.it is very simple you just folow the instructions.</strong></p> <p>1.Open AppDElegate.h file and paste following code.</p> <pre><code>@property(strong,nonatomic) NSString *SharedString; </code></pre> <p>2.Now Open SecondViewController.m and import appDelegate.h</p> <pre><code>#import "AppDelegate.h" </code></pre> <p>3.In SeconViewController.m initialize sharedString with your value</p> <pre><code>ViewDidLoad { AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; appdelegate.SharedString=@"Any String"; } </code></pre> <ol> <li><p>Open FirstViewController.m and import appDelegate.h</p> <p>#import "AppDelegate.h"</p></li> </ol> <p>5.In FirstViewController.m paste Following Code</p> <pre><code>- (void)viewDidAppear:(BOOL)animated { AppDelegate *appdelegate = [[UIApplication sharedApplication] delegate]; self.YouLable.text = appdelegate.SharedString; [super viewDidAppear:NO]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload