On-disk store of the boxes for your object types.
In every app, you have to setup a
Storeonly once and call
register(entity:)for each entity type to set the store up. Afterwards, you can obtain
Boxinstances with the
box(for:)methods. Boxes provide the interfaces for object persistence.
The code generator will create a convenience initializer for you to use, with sensible defaults set:
A typical setup sequence looks like this:
let store = try Store(directoryPath: pathToStoreData) store.register(entity: Person.self) let personBox = store.box(for: Person.self) let persons = personBox.all()
class Store : NSObject
A box to store objects of a particular type.
public class Box<E> where E: Store.InspectableEntity
Base protocol of anything you want to persist in a box.
All stored properties of a type that conforms to
Entitywill be persisted, if possible. For numbers, ObjectBox recognizes
Double. It also recognizes
public protocol Entity : AnyObject
Object identifier type.
Object identifiers are wrappers for
EntityIdvalues which are
UInt64. These are used for persisted objects. Identifiers are assigned by the framework automatically when you call
A value ofSee more
0indicates the object hasn’t been persisted, yet.