Input the code below in the RootViewController
:
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString*yourStringNameHere = [NSString stringWithFormat:@"%@",cell.textLabel.text];
NSLog(@"%@",yourStringNameHere);//this isn't used in retreiving the info
NSNumber *number = [NSNumber numberWithInt:1];
NSDictionary *yourDictionaryNameHere = [NSDictionary dictionaryWithObjectsAndKeys:
yourStringNameHere, @"yourStringNameHereDictionary",nil];
Input the code below in the DetailViewController
:
In the header file(.h) put
IBOutlet UILabel *yourLabelNameHere;
In the main file(.m) use
yourLabelNameHere.text= [yourDictionaryNameHere objectForKey:(@"yourStringNameHereDictionary")];
Notes:
- If you can't have access the dictionary put #import "RootViewController.h"
- We use the NSDictionary to store data on the iPhone memory, this allows us to use the data from the other class, otherwise with just using #import you only receive the data from the initialization of the variable.
- Receive a string from the NSDictionary from a key
- Set up a UILabel in the
DetailViewController.h
that outputs to a storyboard or xib file
- For loading the label at the start of the transition, put the dictionary receiver in
ViewDidLoad
or a method(-(void)function)
called by ViewDidLoad