1

I am PHP programmer and I'm starting with Swift and object-oriented programming and come. I intend to develop an application based on tables with a SQLite database, something simple, but I'm sure in which to properly desenolver it.

Ahead of the site schedule, I figured it would be basically the same way to program, that is, on the first page I search the database the information that I will use on that page (eg product name) and when the user clicks this product, the link would take you to another page and there again I would connect me with the database and through the ID passed to this new page, I'd get all product information in question (eg. product image, product details, value, etc.)

So, I figured that the same would happen with my application, ie I only spend the ID of a ViewContoller to another, and both View I would connect me with the database and would take the information that I would use for each View. Seeing some tutorials, I realized that were made differently. On the first view, all information is captured and linked as properties of an object. And in this case rather than sending the ID, the View would send the entire object to another View.

My question is what the correct way to program if I have a lot of information to present. In my case here, I have more than 3,600 products and this product has over 8 properties (long texts) each.

Leandro Parice
  • 1,096
  • 11
  • 11
  • possible duplicate of [How do you share data between view controllers and other objects in Swift?](http://stackoverflow.com/questions/29734954/how-do-you-share-data-between-view-controllers-and-other-objects-in-swift) – nhgrif Jun 25 '15 at 22:47
  • This question is somewhere between a duplicate and too broad. – nhgrif Jun 25 '15 at 22:48

1 Answers1

0
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
        if (segue.identifier == "Foobar") {
            if let viewController = segue.destinationViewController as? FoobarViewController {
                viewController.somedata = dataInThisController
            }

        }
 }
Gene De Lisa
  • 3,628
  • 1
  • 21
  • 36
  • Many thanks for the answer, but it's not exactly my question, I would like to know the best way to work when using and enjoying lots of data. I create all objects in the first view and move the object to another view, or each view should connect to the database and get the necessary data? (In this case I only pass to the other view the record ID in the database data) – Leandro Parice Jun 27 '15 at 03:57