Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON data UITableView to UITableView
    text
    copied!<p>iam not very good at coding,i have a serious problem in my code,i want to show my json data from one talbe to another,forexample:in the first tableview i would like to show the Students" name, and after the name is clicked, it shall jump to next tableview and show the course that this student had been chosen(one student may have more than one course),so how can i do it? Here is mycode in the first tableview</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; self.navigationItem.Title = @"選擇類別"; // classify = [[NSArray alloc] initWithObjects: @"時尚類",@"飲食類",@"娛樂類",@"文創類", nil]; // NSString *path = [[NSBundle mainBundle] pathForResource:@"DataList" ofType:@"plist"]; // classify_ = [[NSMutableArray alloc] initWithContentsOfFile : path]; NSURL *url = [NSURL URLWithString:@"http://localhost/store.php"]; NSData *jsonData=[NSData dataWithContentsOfURL:url]; NSError *error = nil; classify_ = [NSJSONSerialization JSONObjectWithData:jsonData options: NSJSONReadingMutableContainers error:&amp;error]; } - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } //table cell count - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self.classify count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell.textLabel.text = [[self.classify objectAtIndex:indexPath.row] objectForKey:@"classify"]; return cell; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Make sure your segue name in storyboard is the same as this line if ([[segue identifier] isEqualToString:@"Second"]) { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; //NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath]; [[segue destinationViewController] setSecondClassify:[self.classify objectAtIndex:indexPath.row]]; } } </code></pre>
 

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