SCArrayOfObjectsModel

@interface SCArrayOfObjectsModel : SCArrayOfItemsModel {
  NSString *searchPropertyName;
}

This class functions as a table view model that is able to represent an array of any kind of objects and automatically generate its cells from these objects. In addition, ‘SCArrayOfObjectsModel’ generates its detail views from the properties of the corresponding object in its items array. Objects in the items array need not all be of the same object type, but they must all decend from NSObject.

‘SCArrayOfItemsModel’ will automatically generate a set of SCArrayOfObjectsSection(s) if the sectionHeaderTitleForItem modelAction is implemented, otherwise it will only generate a single SCArrayOfObjectsSection.

Creation and Initialization

  • Allocates and returns an initialized ‘SCArrayOfObjectsModel’ given a UITableView and an array of objects.

    Declaration

    Objective-C

    + (instancetype)modelWithTableView:(UITableView *)tableView
                                 items:(NSMutableArray *)items
                       itemsDefinition:(SCDataDefinition *)definition;

    Parameters

    tableView

    The UITableView to be bound to the model.

    items

    An array of objects that the model will use to generate its cells. This array must be of type NSMutableArray, as it must support the model’s add, delete, and move operations.

    definition

    The definition of the objects in the objects array.

  • Returns an initialized ‘SCArrayOfObjectsModel’ given a UITableView and an array of objects.

    Declaration

    Objective-C

    - (instancetype)initWithTableView:(UITableView *)tableView
                                items:(NSMutableArray *)items
                      itemsDefinition:(SCDataDefinition *)definition;

    Parameters

    tableView

    The UITableView to be bound to the model.

    items

    An array of objects that the model will use to generate its cells. This array must be of type NSMutableArray, as it must support the model’s add, delete, and move operations.

    definition

    The definition of the objects in the objects array.

Configuration

  • The name of the object’s property that the value of which will be used to search the items array when the user types a search term inside the model’s associated search bar. To search more than one property value, separate the property names by a semi-colon (e.g.: @“firstName;lastName”). To search all properties in the object’s class definition, set the property to an astrisk (e.g.: @“*”). If the property is not set, it defaults to the value of the object’s class definition titlePropertyName property.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *searchPropertyName;

STVCoreData

  • Allocates and returns an initialized SCArrayOfObjectsModel given a UITableView and an entity definition.

    Note

    This method creates a model with all the objects that exist in the definition’s managedObjectContext.

    Declaration

    Objective-C

    + (instancetype)modelWithTableView:(UITableView *)tableView
                      entityDefinition:(SCEntityDefinition *)definition;

    Parameters

    tableView

    The UITableView to be bound to the model.

    definition

    The entity definition of the objects.

  • Allocates and returns an initialized ‘SCArrayOfObjectsModel’ given a UITableView and an entity definition. *

    • - parameter: tableView The UITableView to be bound to the model.
    • - parameter: definition The entity definition of the objects.
    • - parameter: predicate The predicate that will be used to filter the fetched objects.

    Declaration

    Objective-C

    + (instancetype)modelWithTableView:(UITableView *)tableView
                      entityDefinition:(SCEntityDefinition *)definition
                       filterPredicate:(NSPredicate *)predicate;
  • Returns an initialized SCArrayOfObjectsModel given a UITableView and an entity definition.

    Note

    This method creates a model with all the objects that exist in the definition’s managedObjectContext.

    Declaration

    Objective-C

    - (instancetype)initWithTableView:(UITableView *)tableView
                     entityDefinition:(SCEntityDefinition *)definition;

    Parameters

    tableView

    The UITableView to be bound to the model.

    definition

    The entity definition of the objects.

  • Returns an initialized ‘SCArrayOfObjectsModel’ given a UITableView and an entity definition. *

    • - parameter: tableView The UITableView to be bound to the model.
    • - parameter: definition The entity definition of the objects.
    • - parameter: predicate The predicate that will be used to filter the fetched objects.

    Declaration

    Objective-C

    - (instancetype)initWithTableView:(UITableView *)tableView
                     entityDefinition:(SCEntityDefinition *)definition
                      filterPredicate:(NSPredicate *)predicate;