Skip to main content

Overview

An object that represents an instance of a view model, used to update bindings at runtime.
A strong reference to this instance must be maintained if it is being bound to a state machine or artboard, or for observability. If a property is fetched from an instance different to that bound to an artboard or state machine, its value or trigger will not be updated.

Properties

name

@property(nonatomic, readonly) NSString* name;
The name of the view model instance.

propertyCount

@property(nonatomic, readonly) NSUInteger propertyCount;
The number of all properties in the view model instance.

properties

@property(nonatomic, readonly) NSArray<RiveDataBindingViewModelInstancePropertyData*>* properties;
An array of property data of all properties in the view model instance.

Methods

propertyFromPath:

- (nullable RiveDataBindingViewModelInstanceProperty*)propertyFromPath:(NSString*)path;
Gets a property from the view model instance. This property is the superclass of all other property types. Parameters:
  • path - The path to the property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

stringPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceStringProperty*)stringPropertyFromPath:(NSString*)path;
Gets a string property in the view model instance. Parameters:
  • path - The path to the string property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

numberPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceNumberProperty*)numberPropertyFromPath:(NSString*)path;
Gets a number property in the view model instance. Parameters:
  • path - The path to the number property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

booleanPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceBooleanProperty*)booleanPropertyFromPath:(NSString*)path;
Gets a boolean property in the view model instance. Parameters:
  • path - The path to the boolean property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

colorPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceColorProperty*)colorPropertyFromPath:(NSString*)path;
Gets a color property in the view model instance. Parameters:
  • path - The path to the color property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

enumPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceEnumProperty*)enumPropertyFromPath:(NSString*)path;
Gets an enum property in the view model instance. Parameters:
  • path - The path to the enum property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

viewModelInstancePropertyFromPath:

- (nullable RiveDataBindingViewModelInstance*)viewModelInstancePropertyFromPath:(NSString*)path;
Gets a view model property in the view model instance. Parameters:
  • path - The path to the view model instance property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

setViewModelInstancePropertyFromPath:toInstance:

- (BOOL)setViewModelInstancePropertyFromPath:(NSString*)path
                                  toInstance:(RiveDataBindingViewModelInstance*)instance;
Replaces a view model property of the view model instance with another instance. Parameters:
  • path - The path to the view model property to replace.
  • instance - The instance to replace the view model property at path with.
Returns: true if the view model instance was replaced, otherwise false.

triggerPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceTriggerProperty*)triggerPropertyFromPath:(NSString*)path;
Returns a trigger property in the view model instance. Parameters:
  • path - The path to the trigger property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

imagePropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceImageProperty*)imagePropertyFromPath:(NSString*)path;
Gets an image property in the view model instance. Parameters:
  • path - The path to the image property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

listPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceListProperty*)listPropertyFromPath:(NSString*)path;
Gets a list property in the view model instance. Parameters:
  • path - The path to the list property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

artboardPropertyFromPath:

- (nullable RiveDataBindingViewModelInstanceArtboardProperty*)artboardPropertyFromPath:(NSString*)path;
Gets an artboard property in the view model instance. Parameters:
  • path - The path to the artboard property.
Returns: The property if it exists at the supplied path, otherwise nil.
Unlike a RiveViewModel.Instance, a strong reference to this type does not have to be made. If the property exists, the underlying property will be cached, and calling this function again with the same path is guaranteed to return the same object.

updateListeners

- (void)updateListeners;
Calls all registered property listeners for the properties of the view model instance.

Build docs developers (and LLMs) love