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:autoGeneratePropertyDefinitions:
-
+ definitionWithEntityName:propertyNamesString:
-
+ definitionWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions:
-
+ definitionWithEntityName:managedObjectContext:propertyNamesString:
-
+ definitionWithEntityName:managedObjectContext:propertyNames:
-
+ definitionWithEntityName:managedObjectContext:propertyNames:propertyTitles:
-
+ definitionWithEntityName:managedObjectContext:propertyGroups:
-
– initWithEntityName:autoGeneratePropertyDefinitions:
-
– initWithEntityName:propertyNamesString:
-
– initWithEntityName:managedObjectContext:autoGeneratePropertyDefinitions:
-
– initWithEntityName:managedObjectContext:propertyNamesString:
-
– initWithEntityName:managedObjectContext:propertyNames:
-
– initWithEntityName:managedObjectContext:propertyNames:propertyTitles:
-
– initWithEntityName:managedObjectContext:propertyGroups:
Configuration
-
entity
property -
managedObjectContext
property -
orderAttributeName
property
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: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.
+ (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.
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.
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.
Declared In
SCEntityDefinition.h
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.
+ (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.
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.
+ (instancetype)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.
+ (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.
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.
+ (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.
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.
+ (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)”.
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
definitionWithEntityName: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.
+ (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)”.
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.
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.
Declared In
SCEntityDefinition.h
Instance Methods
initWithEntityName: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.
- (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.
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.
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.
Declared In
SCEntityDefinition.h
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.
- (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.
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.
- (instancetype)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.
- (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.
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. *
- (instancetype)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.
- (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)”.
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
initWithEntityName:propertyNamesString:
Returns an initialized SCEntityDefinition given a Core Data entity name and a string of the property names to generate property definitions for.
- (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)”.
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.
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.
Declared In
SCEntityDefinition.h