-4

So before you people dock me down on my question, hear me out. I know this is an overly asked question with answers, but I wish to know the best way on how to do this. I created a sharing functionality in my app that allows the app to use the user's data and post on their Facebook (or twitter) that they like my app. For each individual item on my tableviewcontroller I want different message every time. For instance:

if the cell = 1, then message = This if the cell = 2, then message = that etc.

I have a TableViewController .h and .m, and a DisplayViewController .h and .m I need to get the cell data from TableViewController to DisplayViewController.

Should I use Core Data? Is there a non Core Data solution?

Please help

Thanks

doc92606
  • 691
  • 2
  • 11
  • 32
  • Well one usually passes arguments to the initializer for the custom class, or sets properties on the instance after initialization is complete. Is there a reason neither of those solutions works for you? – Jonathan Grynspan Mar 08 '13 at 01:02

1 Answers1

2

The standard Stack Overflow answer of how to pass data between controllers still applies here:

That describes how to pass data between controllers. In terms of determining what you pass from your table view to the next controllers depends upon whether you're using segues or not:

  • If you are not using segues, your didSelectRowAtIndexPath would grab the appropriate data given the indexPath;

  • If you are using segues, your prepareForSegue would just look at your table view's indexPathForSelectedRow to determine what needs to be passed.

Core Data is certainly not needed to pass data between controllers. It's overkill for just passing data between controllers. Frankly, it's solving a different problem, one of data persistence. If you need data that's preserved across separate uses of your app or you're dealing with a lot of data, then some persistent storage makes sense. But nothing you've described here thus far suggests that this is the issue you're wrestling with. Whether you use Core Data or not is simply a very different question, and really doesn't have much to do with passing data between controllers (though it can be used within that context).

Community
  • 1
  • 1
Rob
  • 415,655
  • 72
  • 787
  • 1,044