Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming that you DO want to set the other data source with only this row, you need to pass it as an array.</p> <pre><code>view.anotherviewArray= [NSArray arrayWithObject:[self.arrayFromAFNetworking objectAtIndex:indexPath.row]]; </code></pre> <p>But it's hard to tell from the little code that you have provided. I assume that since you are instantiating the viewController you are also transitioning to it below the provided code. If you are trying to set the array for a viewController already presented, you need to access that one, not create another, perhaps by having saved a reference to it an ivar within the current viewController or another accessible class. </p> <p>I would also not name a ViewController <code>view</code>, it is confusing to anyone reading the code later on. </p> <p>Editing for my comment below about traversing the hierarchy. Here is some code that I used in one iPad project to return the final presented viewController. This method is in the appDelegate. It is somewhat specific to my project, where there is only one navigationController. But you can adapt it to yours. You would test for a viewController that is of the class of your target view controller. </p> <pre><code>- (UIViewController *)topViewController { UIViewController *rootViewController = self.window.rootViewController; UIViewController *topViewController = rootViewController.presentedViewController; while (topViewController &amp;&amp; topViewController.presentedViewController) { topViewController = topViewController.presentedViewController; if ([topViewController isKindOfClass:[UINavigationController class]]) { UIViewController *presentedViewController = [(UINavigationController *) topViewController topViewController]; if (presentedViewController) { topViewController = presentedViewController; } } } return topViewController; } </code></pre> <p>The other approach is to set a property to it when it is created and presented. We don't have enough code to get a good idea of your app as a whole. Where are you creating the ViewController instance that you are displaying? By that I mean where you are calling a segue to it, or pushing it onto a navigationController or call presentViewController. Wherever that is, you need to set a property or ivar to it. Let's say that you use a property in your appDelegate as a very generic case. </p> <p>In your MyAppDelegate.h file you have</p> <pre><code>@property(nonatomic,strong) ViewController *viewController; </code></pre> <p>Wherever you first create it you set that property </p> <pre><code>MyAppDelegate *appDelegate = (MyAppDelegate*)[[UIApplication sharedApplication] delegate]; appDelegate.viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; </code></pre> <p>I now think you are trying to add this to a mutableArray in the other ViewController. Then replacing your code from the tableViewCell above you would use MyAppDelegate <em>appDelegate = (MyAppDelegate</em>)[[UIApplication sharedApplication] delegate]; [appDelegate.viewController.mutableDataArray addObject:self.arrayFromAFNetworking objectAtIndex:indexPath.row]; [appDelegate.viewController.tableView reloadData];</p> <p>I will say that it is not great practice to use the appDelegate for the property. But it is a generic answer that would work. It's best to put it in a class which is common to the viewControllers that you are passing data between. Perhaps a single parent which holds these two viewControllers? </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.
    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