Note that there are some explanatory texts on larger screens.

plurals
  1. POSending NSString to viewController returns a null
    primarykey
    data
    text
    <p>I sent a NSString to a viewController, tried to log it from another viewController, and it turned null. My code is below</p> <hr> <p>Edit: Im deleting all code and showing my code from my application. Because I am still getting (null)</p> <h2>HabitViewController.h</h2> <pre><code> #import &lt;UIKit/UIKit.h&gt; @interface HabitViewController : UITableViewController { NSString *cellName2; } @property(nonatomic,retain) NSString *cellName2; @end </code></pre> <h2>HabitViewController.m</h2> <pre><code>@synthesize cellName2; - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@",cellName2); } </code></pre> <hr> <h2>DetailViewController.h</h2> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface DetailViewController : UIViewController { NSString *cellName; } @property(nonatomic,retain) NSString *cellName; @end </code></pre> <h2>DetailViewController.m</h2> <pre><code>#import "DetailViewController.h" #import "HabitViewController.h" @end @implementation DetailViewController @synthesize cellName; #pragma mark - Managing the detail item - (void)viewDidLoad { [super viewDidLoad]; cellName = @"Hello World"; HabitViewController *obj = [[HabitViewController alloc] init]; obj.cellName2 = cellName; } </code></pre> <p>I left a lot of code out, because they had nothing to do with my problem.</p> <hr> <h2>Edit</h2> <p>Based on Jsdodgers comments and answer, I have updated My question :</p> <p>habitViwController.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface HabitViewController : UITableViewController { } @property(nonatomic,retain) NSString *cellName2; @end </code></pre> <p>.m</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@",self.cellName2); } </code></pre> <hr> <p>DetailViewController.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface DetailViewController : UIViewController { } @property(nonatomic,retain) NSString *cellName; @end </code></pre> <p>.m</p> <pre><code>@synthesize cellName; - (void)viewDidLoad { [super viewDidLoad]; cellName = @"Hello World"; HabitViewController *obj = [[HabitViewController alloc] init]; obj.cellName2 = self.cellName; [self configureView]; } </code></pre> <p>But I still dont have any success. Still says (null)</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.
    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