SCEntityDefinition

@interface SCEntityDefinition : SCDataDefinition

This class functions as a means to further extend the definition of user-defined Core Data entities. Using entity definitions, classes like SCObjectCell and SCObjectSection will be able to better generate user interface elements that truly represent the properties of their bound objects.

SCEntityDefinition mainly consists of one or more property definitions of type SCPropertyDefinition. Upon creation, SCEntityDefinition will (optionally) automatically generate all the property definitions for the given entity. From there, the user will be able to customize the generated property definitions, add new definitions, or remove generated definitions.

Sample use: // Extend the definition of ‘TaskEntity’ (user defined Core Data entity) SCEntityDefinition *taskDef = [SCEntityDefinition definitionWithEntityName:@“TaskEntity” managedObjectContext:context propertyNamesString:@“Task Details:(name,description,category,dueDate);Task Status:(completed)”]; SCPropertyDefinition *namePropertyDef = [taskDef propertyDefinitionWithName:@“name”]; namePropertyDef.required = TRUE; SCPropertyDefinition *descPropertyDef = [taskDef propertyDefinitionWithName:@“description”]; descPropertyDef.type = SCPropertyTypeTextView; SCPropertyDefinition *categoryPropertyDef = [taskDef propertyDefinitionWithName:@“category”]; categoryPropertyDef.type = SCPropertyTypeSelection; NSArray *categoryItems = [NSArray arrayWithObjects:@“Home”, @“Work”, @“Other”, nil]; categoryPropertyDef.attributes = [SCSelectionAttributes attributesWithItems:categoryItems allowMultipleSelection:NO allowNoSelection:NO];

See

SCPropertyDefinition.

Creation and Initialization

  • Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and the option to auto generate property definitions for the given entity’s properties.

    The method will also generate user friendly property titles from the names of the generated properties. These titles can be modified by the user later as part of the property definition customization.

    Warning

    Note: This method attempts to automatically determine the required NSManagedObjectContext by querying the current app delegate. If your app delegate does not provide an NSManagedObjectContext, or if you’d like to provide a diffrerent one, please use definitionWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions: instead.

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
             autoGeneratePropertyDefinitions:(BOOL)autoGenerate;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    autoGenerate

    If TRUE, ‘SCClassDefinition’ will automatically generate all the property definitions for the given entity’s attributes.

  • Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.

    The method will also generate user friendly property titles from the names of the given properties. These titles can be modified by the user later as part of the property definition customization.

    Property names string syntax options: @“property1;property2;property3;…” @“group1 header:(property1, property2,…):group1 footer;group2…”

    Warning

    Note: This method attempts to automatically determine the required NSManagedObjectContext by querying the current app delegate. If your app delegate does not provide an NSManagedObjectContext, or if you’d like to provide a diffrerent one, please use definitionWithEntityName:managedObjectContext:propertyNamesString: instead.

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
                         propertyNamesString:(NSString *)propertyNamesString;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    propertyNamesString

    A string with the property names separated by semi-colons. Example string: @“firstName;lastName”. Property groups can also be defined in the string using the following format: @“Personal Details:(firstName, lastName); Address:(street, state, country)”. The group title can also be ommitted to create a group with no title. For example: @“:(firstName, lastName)”.

  • Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and the option to auto generate property definitions for the given entity’s properties.

    The method will also generate user friendly property titles from the names of the generated properties. These titles can be modified by the user later as part of the property definition customization.

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
                        managedObjectContext:(NSManagedObjectContext *)context
             autoGeneratePropertyDefinitions:(BOOL)autoGenerate;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    autoGenerate

    If TRUE, ‘SCClassDefinition’ will automatically generate all the property definitions for the given entity’s attributes.

  • Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.

    The method will also generate user friendly property titles from the names of the given properties. These titles can be modified by the user later as part of the property definition customization.

    Property names string syntax options: @“property1;property2;property3;…” @“group1 header:(property1, property2,…):group1 footer;group2…”

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
                        managedObjectContext:(NSManagedObjectContext *)context
                         propertyNamesString:(NSString *)propertyNamesString;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    propertyNamesString

    A string with the property names separated by semi-colons. Example string: @“firstName;lastName”. Property groups can also be defined in the string using the following format: @“Personal Details:(firstName, lastName); Address:(street, state, country)”. The group title can also be ommitted to create a group with no title. For example: @“:(firstName, lastName)”.

  • Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and an array of the property names to generate property definitions for.

    The method will also generate user friendly property titles from the names of the given properties. These titles can be modified by the user later as part of the property definition customization.

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
                        managedObjectContext:(NSManagedObjectContext *)context
                               propertyNames:(NSArray *)propertyNames;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    propertyNames

    An array of the names of properties to be generated. All array elements must be of type NSString.

  • Allocates and returns an initialized ‘SCEntityDefinition’ given a Core Data entity name, an array of the property names to generate property definitions for, and array of titles for these properties.

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
                        managedObjectContext:(NSManagedObjectContext *)context
                               propertyNames:(NSArray *)propertyNames
                              propertyTitles:(NSArray *)propertyTitles;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    propertyNames

    An array of the names of properties to be generated. All array elements must be of type NSString.

    propertyTitles

    An array of titles to the properties in propertyNames. All array elements must be of type NSString.

  • Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and an SCPropertyGroupArray.

    • - parameter: entityName The name of the entity for which the definition will be extended.
    • - parameter: context The managed object context of the entity.
    • - parameter: groups A collection of property groups.

    Declaration

    Objective-C

    + (instancetype)definitionWithEntityName:(NSString *)entityName
                        managedObjectContext:(NSManagedObjectContext *)context
                              propertyGroups:(SCPropertyGroupArray *)groups;
  • Returns an initialized SCEntityDefinition given a Core Data entity name and the option to auto generate property definitions for the given entity’s properties.

    The method will also generate user friendly property titles from the names of the generated properties. These titles can be modified by the user later as part of the property definition customization.

    Warning

    Note: This method attempts to automatically determine the required NSManagedObjectContext by querying the current app delegate. If your app delegate does not provide an NSManagedObjectContext, or if you’d like to provide a diffrerent one, please use initWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions: instead.

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
        autoGeneratePropertyDefinitions:(BOOL)autoGenerate;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    autoGenerate

    If TRUE, SCEntityDefinition will automatically generate all the property definitions for the given entity’s attributes.

  • Returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.

    The method will also generate user friendly property titles from the names of the given properties. These titles can be modified by the user later as part of the property definition customization.

    Property names string syntax options: @“property1;property2;property3;…” @“group1 header:(property1, property2,…):group1 footer;group2…”

    Warning

    Note: This method attempts to automatically determine the required NSManagedObjectContext by querying the current app delegate. If your app delegate does not provide an NSManagedObjectContext, or if you’d like to provide a diffrerent one, please use initWithEntityName:managedObjectContext:propertyNamesString: instead.

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
                   propertyNamesString:(NSString *)propertyNamesString;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    propertyNamesString

    A string with the property names separated by semi-colons. Example string: @“firstName;lastName”. Property groups can also be defined in the string using the following format: @“Personal Details:(firstName, lastName); Address:(street, state, country)”. The group title can also be ommitted to create a group with no title. For example: @“:(firstName, lastName)”.

  • Returns an initialized SCEntityDefinition given a Core Data entity name and the option to auto generate property definitions for the given entity’s properties.

    The method will also generate user friendly property titles from the names of the generated properties. These titles can be modified by the user later as part of the property definition customization.

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
                   managedObjectContext:(NSManagedObjectContext *)context
        autoGeneratePropertyDefinitions:(BOOL)autoGenerate;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    autoGenerate

    If TRUE, SCEntityDefinition will automatically generate all the property definitions for the given entity’s attributes.

  • Returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.

    The method will also generate user friendly property titles from the names of the given properties. These titles can be modified by the user later as part of the property definition customization.

    Property names string syntax options: @“property1;property2;property3;…” @“group1 header:(property1, property2,…):group1 footer;group2…”

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
                  managedObjectContext:(NSManagedObjectContext *)context
                   propertyNamesString:(NSString *)propertyNamesString;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    propertyNamesString

    A string with the property names separated by semi-colons. Example string: @“firstName;lastName”. Property groups can also be defined in the string using the following format: @“Personal Details:(firstName, lastName); Address:(street, state, country)”. The group title can also be ommitted to create a group with no title. For example: @“:(firstName, lastName)”.

  • Returns an initialized SCEntityDefinition given a Core Data entity name and an array of the property names to generate property definitions for.

    The method will also generate user friendly property titles from the names of the given properties. These titles can be modified by the user later as part of the property definition customization.

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
                  managedObjectContext:(NSManagedObjectContext *)context
                         propertyNames:(NSArray *)propertyNames;

    Parameters

    entityName

    The name of the entity for which the definition will be extended.

    context

    The managed object context of the entity.

    propertyNames

    An array of the names of properties to be generated. All array elements must be of type NSString.

  • Returns an initialized SCEntityDefinition given a Core Data entity name, an array of the property names to generate property definitions for, and array of titles for these properties. *

    • - parameter: entityName The name of the entity for which the definition will be extended.
    • - parameter: context The managed object context of the entity.
    • - parameter: propertyNames An array of the names of properties to be generated. All array elements must be of type NSString.
    • - parameter: propertyTitles An array of titles to the properties in propertyNames. All array elements must be of type NSString. *

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
                  managedObjectContext:(NSManagedObjectContext *)context
                         propertyNames:(NSArray *)propertyNames
                        propertyTitles:(NSArray *)propertyTitles;
  • Returns an initialized SCEntityDefinition given a Core Data entity name and an SCPropertyGroupArray.

    • - parameter: entityName The name of the entity for which the definition will be extended.
    • - parameter: context The managed object context of the entity.
    • - parameter: groups A collection of property groups.

    Declaration

    Objective-C

    - (instancetype)initWithEntityName:(NSString *)entityName
                  managedObjectContext:(NSManagedObjectContext *)context
                        propertyGroups:(SCPropertyGroupArray *)groups;

Configuration

  • The entity associated with the definition.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSEntityDescription *entity;
  • The managed object context of the entity associated with the definition.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext;
  • The name of the entity attribute that will be used to store the display order of its objects.

    Setting this property to a valid attribute name allows for custom re-ordering of the generated user interface elements representing the Core Data objects (e.g. custom re-ordering of cells). Setting this property overrides the value set for the keyPropertyName property.

    Warning

    Important: This Core Data attribute must be of integer type.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *orderAttributeName;