Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing id from Parse table view to a detail view
    text
    copied!<p>(I know this has been asked before, unfortunately none of the related StackOverflow answers I've looked through and tried out while trying to figure this problem out have worked for me. Any help would be much appreciated.)</p> <p>I'm building a simple news app. The opening screen grabs the latest news entry using Parse's API.</p> <p><img src="https://i.stack.imgur.com/vg0l3.png" alt="First screen"></p> <p>And when you tap the menu button, you get a UITableView of past news days:</p> <p><img src="https://i.stack.imgur.com/QzaRr.png" alt="Sliding menu"></p> <p>I want to be able to pass the id from the selected Parse table cell back to the main view.</p> <p>I'm using ECSlidingViewController for the sliding menu and a Storyboard for the various screens:</p> <p><img src="https://i.stack.imgur.com/fvz42.png" alt="The Storyboard"></p> <p>But because of the way I'm using ECSlidingViewController, I can't figure out how to pass data via segues like I otherwise would be able to, so I'm trying to just pass it via the view controllers with a custom init.</p> <p>Here's my MainViewController.h code:</p> <pre><code>@interface MainViewController : UIViewController @property (nonatomic) NSString *detailId; - (id)initWithDetailId:(NSString*)theId; @end </code></pre> <p>Here's my <code>didSelectRowAtIndexPath</code> code in MenuViewController.m:</p> <pre><code>MainViewController *mainVC = [[MainViewController alloc] initWithDetailId:@"test"]; [self.navigationController pushViewController:mainVC animated:YES]; </code></pre> <p>Here's MainViewController.m's <code>initWithDetailId</code>:</p> <pre><code>- (id)initWithDetailId:(NSString*)theId { NSLog(@"initWithDetailId"); self = [super initWithNibName:nil bundle:nil]; if (self) { detailId = theId; } return self; } </code></pre> <p>And here's MainViewController.m's <code>viewDidLoad</code>:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"detailId equals: %@", self.detailId); } </code></pre> <p>But all I get from the NSLog is "detailId equals: (null)". What am I doing wrong here? Thanks!</p>
 

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