Other Classes

The following classes are available globally.

  • AsyncBox is a class that lets you asynchronously perform basic database write operations. Your program can just fire off these operations and forget about them, and they’ll be executed for you on a background thread, without blocking your UI or the like until writes have completed.

    Important

    AsyncBox does not report errors that occur in asynchronous execution.
    See more

    Declaration

    Swift

    public class AsyncBox<E: EntityInspectable & __EntityRelatable>
    where E == E.EntityBindingType.EntityType
  • Combine publisher for an ObjectBox box. You obtain an instance of this type via the publisher property on Box.

    See more

    Declaration

    Swift

    @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    public class BoxPublisher<E>: Publisher
    where E: EntityInspectable & __EntityRelatable, E.EntityBindingType.EntityType == E
  • Combine publisher for an ObjectBox query. You obtain an instance of this type via the publisher property on Query.

    See more

    Declaration

    Swift

    @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
    public class QueryPublisher<E>: Publisher
    where E: EntityInspectable & __EntityRelatable, E.EntityBindingType.EntityType == E
  • Class used together with ModelBuilder by the code generator to specify the fields and their indexes in an entity. Typical usage is:

    let eBuilder = mBuilder.entityBuilder(for: MyEntity.self, id: 1, uid: 1001)
    eBuilder.addProperty(name: "id", type: .long, flags: [.id, .unsigned], id: 1, uid: 1001)
    eBuilder.addProperty(name: "userName", type: .string, id: 2, uid: 1002)
    eBuilder.lastProperty(id: 2, uid: 1002)
    

    and so on. Note that there may be only one EntityBuilder in existence at any one time. It is currently not supported to use a previous EntityBuilder after creating a new one using ModelBuilder‘s entityBuilder() method. See ModelBuilder for more.

    You usually don’t have to deal with this class.

    See more

    Declaration

    Swift

    public class EntityBuilder<T>
  • Used by the code generator to associate a Swift class with its counterpart in the model of the ObjectBox database.

    See more

    Declaration

    Swift

    public class EntityInfo
  • Class used by the code generator to create a model for your Store. Typical usage is:

    let mBuilder = ModelBuilder()
    let eBuilder = mBuilder.entityBuilder(for: myEntityInfo, id: 1, uid: 1001)
    // ... set up the entity here
    mBuilder.lastEntity(id: 1, uid: 1001)
    mBuilder.lastIndex(id: 0, uid: 0) // This example model has no indexes.
    let model = mBuilder.finish()
    // create new Store using the model
    

    See EntityBuilder documentation for details.

    You usually don’t have to deal with this class.

    See more

    Declaration

    Swift

    public class ModelBuilder
  • Used by generated Swift code to get properties from an entity to store them.

    See more

    Declaration

    Swift

    public class FlatBufferBuilder
  • An opaque object that serves as a reference to a change subscription on a Box or Query. Keep a strong reference to this object (in a property or a global) as long as you want to receive callbacks. Let this object deinit to cancel your subscription.

    You obtain an Observer from one of a Box‘s or Query’s subscribe() methods.

    See more

    Declaration

    Swift

    public class Observer
  • An object that describes a query. You usually interact with a QueryBuilder solely via Box’s query() method, but certain properties that can’t be modified on a query once it has been built (like sort order) can be configured on the QueryBuilder. Call build() on a QueryBuilder to create an actual query object that you can request objects from.

    See more

    Declaration

    Swift

    public final class QueryBuilder<E: EntityInspectable & __EntityRelatable>
    where E == E.EntityBindingType.EntityType