SCEntityDefinition Class Reference
Inherits from | SCDataDefinition : NSObject |
Declared in | SCEntityDefinition.h |
Overview
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];
Tasks
Creation and Initialization
-
+ definitionWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions:
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.
-
+ definitionWithEntityName:managedObjectContext:propertyNamesString:
Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.
-
+ definitionWithEntityName:managedObjectContext:propertyNames:
Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and an array of the property names to generate property definitions for.
-
+ definitionWithEntityName:managedObjectContext:propertyNames:propertyTitles:
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.
-
+ definitionWithEntityName:managedObjectContext:propertyGroups:
Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and an SCPropertyGroupArray.
-
– initWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions:
Returns an initialized SCEntityDefinition given a Core Data entity name and the option to auto generate property definitions for the given entity’s properties.
-
– initWithEntityName:managedObjectContext:propertyNamesString:
Returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.
-
– initWithEntityName:managedObjectContext:propertyNames:
Returns an initialized SCEntityDefinition given a Core Data entity name and an array of the property names to generate property definitions for.
-
– initWithEntityName:managedObjectContext:propertyNames:propertyTitles:
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. * * @param entityName The name of the entity for which the definition will be extended. * @param context The managed object context of the entity. * @param propertyNames An array of the names of properties to be generated. All array elements must be of type NSString. * @param propertyTitles An array of titles to the properties in propertyNames. All array elements must be of type NSString. *
-
– initWithEntityName:managedObjectContext:propertyGroups:
Returns an initialized SCEntityDefinition given a Core Data entity name and an SCPropertyGroupArray.
Configuration
-
entity
The entity associated with the definition.
property -
managedObjectContext
The managed object context of the entity associated with the definition.
property -
orderAttributeName
propertyThe name of the entity attribute that will be used to store the display order of its objects.
Properties
entity
The entity associated with the definition.
@property (nonatomic, readonly, strong) NSEntityDescription *entity
Declared In
SCEntityDefinition.h
managedObjectContext
The managed object context of the entity associated with the definition.
@property (nonatomic, readonly, strong) NSManagedObjectContext *managedObjectContext
Declared In
SCEntityDefinition.h
orderAttributeName
The name of the entity attribute that will be used to store the display order of its objects.
@property (nonatomic, copy) NSString *orderAttributeName
Discussion
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.
Declared In
SCEntityDefinition.h
Class Methods
definitionWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions:
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.
+ (id)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.
Discussion
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.
Declared In
SCEntityDefinition.h
definitionWithEntityName:managedObjectContext:propertyGroups:
Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and an SCPropertyGroupArray.
+ (id)definitionWithEntityName:(NSString *)entityName managedObjectContext:(NSManagedObjectContext *)context propertyGroups:(SCPropertyGroupArray *)groups
Parameters
- entityName
The name of the entity for which the definition will be extended.
- context
The managed object context of the entity.
- groups
A collection of property groups.
Declared In
SCEntityDefinition.h
definitionWithEntityName:managedObjectContext:propertyNames:
Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and an array of the property names to generate property definitions for.
+ (id)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.
Discussion
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.
Declared In
SCEntityDefinition.h
definitionWithEntityName:managedObjectContext:propertyNames:propertyTitles:
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.
+ (id)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.
Declared In
SCEntityDefinition.h
definitionWithEntityName:managedObjectContext:propertyNamesString:
Allocates and returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.
+ (id)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)”.
Property names string syntax options:
@"property1;property2;property3;..." @"group1 header:(property1, property2,...):group1 footer;group2..."
Discussion
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.
Declared In
SCEntityDefinition.h
Instance Methods
initWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions:
Returns an initialized SCEntityDefinition given a Core Data entity name and the option to auto generate property definitions for the given entity’s properties.
- (id)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.
Discussion
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.
Declared In
SCEntityDefinition.h
initWithEntityName:managedObjectContext:propertyGroups:
Returns an initialized SCEntityDefinition given a Core Data entity name and an SCPropertyGroupArray.
- (id)initWithEntityName:(NSString *)entityName managedObjectContext:(NSManagedObjectContext *)context propertyGroups:(SCPropertyGroupArray *)groups
Parameters
- entityName
The name of the entity for which the definition will be extended.
- context
The managed object context of the entity.
- groups
A collection of property groups.
Declared In
SCEntityDefinition.h
initWithEntityName:managedObjectContext:propertyNames:
Returns an initialized SCEntityDefinition given a Core Data entity name and an array of the property names to generate property definitions for.
- (id)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.
Discussion
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.
Declared In
SCEntityDefinition.h
initWithEntityName:managedObjectContext:propertyNames:propertyTitles:
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. * * @param entityName The name of the entity for which the definition will be extended. * @param context The managed object context of the entity. * @param propertyNames An array of the names of properties to be generated. All array elements must be of type NSString. * @param propertyTitles An array of titles to the properties in propertyNames. All array elements must be of type NSString. *
- (id)initWithEntityName:(NSString *)entityName managedObjectContext:(NSManagedObjectContext *)context propertyNames:(NSArray *)propertyNames propertyTitles:(NSArray *)propertyTitles
Declared In
SCEntityDefinition.h
initWithEntityName:managedObjectContext:propertyNamesString:
Returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.
- (id)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)”.
Property names string syntax options:
@"property1;property2;property3;..." @"group1 header:(property1, property2,...):group1 footer;group2..."
Discussion
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.
Declared In
SCEntityDefinition.h