0
votes

I have got an tableView, so when the cell is tapped it diverts to a DetailViewController. But it doesn´t have any data in it, such as images or text. How do I pass this data to my DetailView?

Code for controllers:

.h file

@interface Sushi : NSObject { IBOutlet UILabel *sushiDescription; IBOutlet UIImageView *sushiPicture; }

@property (nonatomic, retain) IBOutlet UILabel *sushiDescription; @property (nonatomic, retain) IBOutlet UIImageView *sushiPicture;

@end

.m file

@implementation Sushi

@synthesize sushiDescription, sushiPicture;

-(void)dealloc { [sushiDescription release]; [sushiPicture release]; [super dealloc]; }

@end

1
one more thing, I am a beginner so please go in depth when you answer.Souljacker
thanks, but I have read Learning iPhone Programming by Oreily, chapter: TableView Based Apps. And I just want a simpler tutorial on how to do what it says in Oreily´s book.Souljacker
What have you tried? What specifically are you having difficulty with from the book's example? Give some specifics about your case. What data are your table view's cells showing? What does the DetailViewController need to know to show the detail?user467105
I don't have that book so I don't know what technique it's showing. There are many ways to pass data. If you give some code from the example or your didSelectRowAtIndexPath method, people might be able to give a good answer. Generally, I prefer to add properties to the detail view controller that the main controller sets before presenting the detail view controller.user467105

1 Answers

2
votes

For sample do like this,

1) Store any value ex:the indexpath.row vale in appdelegate

2)In DetailViewController's viewDidLoad access the value and display it accordingly