As we can see with the previous recipe, sometimes, our old friend NSSet
is not enough to solve our problems, so in this recipe, we will create our own set. The goal of this recipe is not only to show how you could create your own set, but also to overload operators.
For this recipe, we will create a simple shopping list program, where the user can write the product that he needs to buy and its quantity. If he tries to add it twice, the product will not appear twice, rather it will sum the quantity to the existing product.
There will be a switch button that when disabled means the user won't be able to add the product to the shopping list if it already exists, and of course, there will be a button to display our list.