Note that there are some explanatory texts on larger screens.

plurals
  1. POsegue data passing returns nil
    primarykey
    data
    text
    <p>I need to pass a NSString to my other ViewController but it keeps returning nil.</p> <pre><code>//prepareForSegue is called from didSelectRowAtIndexPath - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([[segue identifier] isEqualToString:@"chat"]) { NSString *userName = (NSString *) [toUsersArray objectAtIndex:[self.chatsTableView indexPathForSelectedRow].row]; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ChatViewController *chatViewController = [storyboard instantiateViewControllerWithIdentifier:@"ChatViewController"]; //[chatViewController setChatWithUser:userName]; EVEN TRIED: chatViewController.chatWithUser = username; } } </code></pre> <p>Here is where I declare the NSString:</p> <pre><code>@interface ChatViewController : UIViewController &lt;UITableViewDelegate, UITableViewDataSource, MessageDelegate&gt; { UITextField *messageField; NSString *chatWithUser; UITableView *chatTableView; NSMutableArray *messagesArray; } @property (nonatomic,retain) IBOutlet UITextField *messageField; @property (nonatomic,retain) NSString *chatWithUser; @property (nonatomic,retain) IBOutlet UITableView *chatTableView; - (IBAction) sendMessage; @end </code></pre> <p>and here its still nil:</p> <pre><code> @synthesize chatWithUser; - (void)viewDidLoad { [super viewDidLoad]; //DO STUFF WITH chatWithUser; ADDED BREAKPOINT AND chatWithUser = nil; //ALSO TRIED viewWillAppear; } </code></pre> <p>What is the right way to pass data between these two View Controllers? My variables stay nil.</p>
    singulars
    1. This table or related slice is empty.
    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. 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