draion
draion

Reputation: 443

Passing an array from one view controller to the another view controller

I have read all of the posts about passing data from one view controller to another but I am still at a loss as to how that is done. Simply put, I have an array that is built in my MainViewController and need to use that array in my DisplayViewController.

I am simply doing the following

//DisplayViewController
self.items = mainViewController.items

I would think that this notation would work but I keep getting the following error: Request for member 'mainViewController' in something not a structure or union.

Since I am a real newbie I cannot really understand some of the answers that I read. So if someone can put it in laymans terms, I would really appreciate it!!!

Upvotes: 0

Views: 675

Answers (1)

Johan Kool
Johan Kool

Reputation: 15937

Usually it's done the other way around. Just before you push your DisplayViewController on the stack (or however you make it visible), you set its items property.

detailViewController.items = self.items;
[self.navigationController pushViewController:detailViewController animated:YES];

Upvotes: 1

Related Questions