Note that there are some explanatory texts on larger screens.

plurals
  1. PONSLog returns (null) when logging string from another view controller
    primarykey
    data
    text
    <p>I posted a question earlier about the same thing, but now I have made a simple project to show what I am doing, so the problem can be found easier.</p> <p>I have two viewControllers, one is called ViewController and the other SecondViewController. I tried sending a NSString called testy to a viewController and logging it, but it returned null.</p> <p>Here is my code trying to send the string from viewController to secondViewController</p> <h1>ViewController.m</h1> <pre><code>#import "ViewController.h" #import "SecondViewController.h" @interface ViewController () @end @implementation ViewController @synthesize cellName; - (void)viewDidLoad { [super viewDidLoad]; cellName = @"testy"; SecondViewController *obj = [[SecondViewController alloc] init]; obj.cellName2 = self.cellName; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end </code></pre> <h1>ViewController.h</h1> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ViewController : UIViewController { } @property(nonatomic,retain) NSString *cellName; @end </code></pre> <hr> <h1>SecondViewController.m</h1> <pre><code>#import "SecondViewController.h" #import "ViewController.h" @interface SecondViewController () @end @implementation SecondViewController @synthesize cellName2; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)viewDidAppear:(BOOL)animated { NSLog(@"%@",cellName2); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end </code></pre> <h1>SecondViewController.h</h1> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface SecondViewController : UIViewController { } @property(nonatomic,retain) NSString *cellName2; @end </code></pre> <hr> <h1>Edit</h1> <p>I would like to say that my storyboard has two viewController that each have a button. Each button modally brings you to the other view. </p>
    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.
 

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