Name the file Category.swift and give your new model a single String property named name. The challenge is to create a Category model by yourself. Specimens should be separated into different categories. With your first model created in Realm, are you ready to use this knowledge in a small challenge? Date() returns the current date so the property is initialized with that value. Here, you set the type to Double and initialize them with 0.0.Ĭreated stores the creation date of the specimen. Latitude and longitude store the coordinates for the specimen. In this case, you initialize them with an empty string. Specific data types in Realm, such as strings, must be initialized with a value. Name and specimenDescription store the specimen’s name and description. Open Specimen.swift from the Models group and add the following implementation:Ĭlass Specimen: Object dynamic var name = dynamic var specimenDescription = dynamic var latitude = dynamic var longitude = dynamic var created = Date() With a brief introduction to Realm, it’s time to get your feet wet and build the rest of the project. They have many similarities with regular Arrays including the subscript syntax.
0 Comments
Leave a Reply. |