I’m working on a unit converter app and I want to be able to convert several categories of objects (length, height, mass, temperature, etc). I also want to use core data to store the conversion factors so I’m not writing hundreds of if statements. How should I structure my data model? Should I have an entity for each category of conversions?
Thanks
Make a class
Category, which will have a stringname(length, mass, charge, etc.) and a many-to-one relationship withUnit, which will have aname,abbreviation, andfactor. The factors within each category will obviously need to be scaled to a common unit. You can then ship with a database, and offer users the chance to add their own units if they need one you haven’t provided.