Search code examples
swiftadditionshopping-cart

Add a product in my shopping list - Creating a shopping list app


I've created a product page. Next to the product name, there is a + button. What is supposed to happen when clicking the + button, the product will be added to my cart. How do I do it? I have tried different ways to do it, for example, when clicking the + button a image of the product will show in the cart. But when I press the button, the app crash and I don't know why... Are there any other options for how to do it?

Here is an image of my product page (left) and my cart (right). enter image description here


Solution

  • I see no outlet between your view controllers. Keep in mind that you can only show one view controller at a time. I can also see that you created a big view controller hardly. You should do it programmatically...

    Go on this page : https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/CreateATableView.html , you'll learn how to create Table View, it will be really usefull for what you are trying to do.

    Then you will have to pass data between controller so i suggest you go there : https://learnappmaking.com/pass-data-between-view-controllers-swift-how-to/