Let a user create instances of a class

Hello there,
Im relatively new to swift, and im trying to make a app, i thought about for a while. For this app I want to have sth. like a recipee book. I thought i could use a clas to save the recipees. But i dont want to hardcode the recipees in. That means the User should be able to create a instance of the class. My question now is, how can I do this.
Also it should be possible to search through all the recipees, which means i need some form of index. Can i use an array for this? If yes: how?
thank you in advance
Greetings Kevin

I don’t see why a recipe would need to be passed by reference. Is there a reason you don’t want your recipes to be value types? (The struct should be your default type choice in Swift until it doesn’t make sense for your use case.)

If you’re new to this I’d definitely recommend watching Stanford University’s CS193p course that’s available on YouTube for free.

I definitely think you’d come out of that course with the knowledge to create your recipe app.

1 Like
Terms of Service

Privacy Policy

Cookie Policy