SCDataDefinition Class Reference
Inherits from | NSObject |
Conforms to | SCibInitialization |
Declared in | SCDataDefinition.h |
Overview
This class functions as a means to further extend the definition of user-defined data structures, such as classes and Core Data entities. This enables the framework to automatically generate user interfaces that accurately resemble these structures.
‘SCDataDefinition’ mainly consists of one or more property definitions of type SCPropertyDefinition. The property definitions can be placed in one or more property groups that will control how the properties are grouped when the user interface is generated. If no property groups are assigned, all property definitions are placed in a single defaultPropertyGroup.
See also: SCClassDefinition, SCDictionaryDefinition, SCEntityDefinition, SCWebServiceDefinition
Warning: This is an abstract base class and should never be directly instantiated.
Tasks
Configuration
-
requireEditingModeToEditPropertyValues
property -
keyPropertyName
property -
titlePropertyName
property -
titlePropertyNameDelimiter
property -
descriptionPropertyName
property -
cellActions
property
Managing Property Definitions
-
propertyDefinitionCount
property -
– addPropertyDefinitionWithName:title:type:
-
– addPropertyDefinition:
-
– insertPropertyDefinition:atIndex:
-
– removePropertyDefinitionAtIndex:
-
– removePropertyDefinitionWithName:
-
– propertyDefinitionAtIndex:
-
– propertyDefinitionWithName:
-
– indexOfPropertyDefinitionWithName:
Managing Property Definition Groups
-
defaultPropertyGroup
property -
propertyGroups
property
Internal properties & methods (should only be used by the framework or when subclassing)
-
dataStructureName
property -
– initWithibDictionary:
-
– setupDefaultConfiguration
-
– propertyDataTypeForPropertyWithName:
-
– isValidPropertyName:
-
– titleValueForObject:
-
– objectWithTitle:inObjectsArray:
-
– descriptionValueForObject:
-
– generatePropertiesFromPropertyNamesArray:propertyTitlesArray:
-
– generatePropertiesFromPropertyNamesString:
-
– generateDefaultPropertyGroupProperties
-
– generateCompatibleDataStore
-
– generateCompatibleDataFetchOptions
Properties
cellActions
The set of cell action blocks that will be assigned to all cells generated by the definition’s properties.
@property (nonatomic, readonly) SCCellActions *cellActions
Declared In
SCDataDefinition.h
dataStructureName
The string name of the data structure.
@property (nonatomic, readonly) NSString *dataStructureName
Declared In
SCDataDefinition.h
defaultPropertyGroup
The default property group. The framework will automatically add any properties not included in any other group to this group. If this group has any properties at the time the user interface is generated, it will be rendered as the first group, ahead of all other groups in propertyGroups.
@property (nonatomic, readonly) SCPropertyGroup *defaultPropertyGroup
Discussion
Note: The order of the properties automatically added to this group is the same as their order in the data structure definition.
Warning: Since the framework automatically manages the properties included in this group, adding any properties manually will be ignored.
Declared In
SCDataDefinition.h
descriptionPropertyName
The name of the description property for the data structure.
@property (nonatomic, copy) NSString *descriptionPropertyName
Discussion
Description properties are used in user interface elements to display description information based on the value of the property named here.
Declared In
SCDataDefinition.h
keyPropertyName
The property name that is used to sort the data whenever sorting is requested.
@property (nonatomic, copy) NSString *keyPropertyName
Declared In
SCDataDefinition.h
propertyDefinitionCount
The number of property definitions.
@property (nonatomic, readonly) NSUInteger propertyDefinitionCount
Declared In
SCDataDefinition.h
propertyGroups
An array of all property groups in the class definition. Property groups will be rendered to the user interface with the same order specified in this array.
@property (nonatomic, readonly) SCPropertyGroupArray *propertyGroups
Declared In
SCDataDefinition.h
requireEditingModeToEditPropertyValues
When set to TRUE, the generated user interface elements are required to be placed in ‘Editing Mode’ before the user can modify the generated property controls' values. When not in Editing Mode, all the generated property controls will be put in a read-only state. If the UI was automatically generated by the framework, an ‘Edit’ button will also be automatically added to the navigation bar. Default: FALSE.
@property (nonatomic, readwrite) BOOL requireEditingModeToEditPropertyValues
Declared In
SCDataDefinition.h
titlePropertyName
The name of the title property for the data structure.
@property (nonatomic, copy) NSString *titlePropertyName
Discussion
Title properties are used in user interface elements to display title information based on the value of the property named here. By default, ‘SCDataDefinition’ sets this property to the name of the first property.
Note: To have the title set to more than one property value, separate the property names by a semi-colon (e.g.: @“firstName;lastName”). When displayed, the titles will be separated by the value of the titlePropertyNameDelimiter property.
Declared In
SCDataDefinition.h
titlePropertyNameDelimiter
The delimiter used to separate the titles specified in titlePropertyName. Default: @“ ”.
@property (nonatomic, copy) NSString *titlePropertyNameDelimiter
Declared In
SCDataDefinition.h
Instance Methods
addPropertyDefinition:
Methods adds a new property definition.
- (BOOL)addPropertyDefinition:(SCPropertyDefinition *)propertyDefinition
Parameters
- propertyDefinition
The property definition to be added.
Return Value
Returns TRUE if adding the definition was successful. The main reason for addition failure is if the property name does not match an existing property in the data structure (not required if property definition is an SCCustomPropertyDefinition).
Declared In
SCDataDefinition.h
addPropertyDefinitionWithName:title:type:
Methods adds a new property definition.
- (BOOL)addPropertyDefinitionWithName:(NSString *)propertyName title:(NSString *)propertyTitle type:(SCPropertyType)propertyType
Parameters
- propertyName
The name of the property.
- propertyTitle
The title of the property. If no value is provided, the method automatically generates a user friendly name for the property.
- propertyType
The property type.
Return Value
Returns TRUE if adding the definition was successful. The main reason for addition failure is if the property name does not match an existing property in the data structure.
Declared In
SCDataDefinition.h
descriptionValueForObject:
Returns the description string value for the given object.
- (NSString *)descriptionValueForObject:(NSObject *)object
Discussion
The description value is determined based on the value of the descriptionPropertyName property.
Note: object must be an instance of the data structure defined by the class.
Declared In
SCDataDefinition.h
generateCompatibleDataFetchOptions
Generates a compatible data fetch options object.
- (SCDataFetchOptions *)generateCompatibleDataFetchOptions
Declared In
SCDataDefinition.h
generateCompatibleDataStore
Generates a compatible data store that can be later on used to store data instances of the definition.
- (SCDataStore *)generateCompatibleDataStore
Discussion
Note: Must be implemented by subclasses.
Declared In
SCDataDefinition.h
generateDefaultPropertyGroupProperties
Automatically adds the properties that should be present in defaultPropertyGroup.
- (void)generateDefaultPropertyGroupProperties
Declared In
SCDataDefinition.h
generatePropertiesFromPropertyNamesArray:propertyTitlesArray:
Generates property definitions given an array of property names.
- (void)generatePropertiesFromPropertyNamesArray:(NSArray *)propertyNamesArray propertyTitlesArray:(NSArray *)propertyTitlesArray
Declared In
SCDataDefinition.h
generatePropertiesFromPropertyNamesString:
Generates property definitions given a string with the property names separated by semi-colons.
- (void)generatePropertiesFromPropertyNamesString:(NSString *)propertyNamesString
Declared In
SCDataDefinition.h
indexOfPropertyDefinitionWithName:
Returns the index for the property definition with the given name.
- (NSUInteger)indexOfPropertyDefinitionWithName:(NSString *)propertyName
Parameters
- propertyName
The name of the property whose index to be returned.
Declared In
SCDataDefinition.h
initWithibDictionary:
Should be overridden by subclasses *
- (instancetype)initWithibDictionary:(NSMutableDictionary *)ibDictionary
Declared In
SCDataDefinition.h
insertPropertyDefinition:atIndex:
Methods inserts a new property definition at the given index.
- (BOOL)insertPropertyDefinition:(SCPropertyDefinition *)propertyDefinition atIndex:(NSInteger)index
Parameters
- propertyDefinition
The property definition to be added.
- index
The index to insert the property definition at. Must be less than propertyDefinitionCount.
Return Value
Returns TRUE if inserting the definition was successful. The main reason for insertion failure is if the property name does not match an existing property in the data structure (not required if property definition is an SCCustomPropertyDefinition).
Declared In
SCDataDefinition.h
isValidPropertyName:
Returns TRUE if propertyName is valid.
- (BOOL)isValidPropertyName:(NSString *)propertyName
Parameters
- propertyName
The name of the property whose validity is to be checked.
Discussion
A propertyName is valid if it exists within the defined data structure.
Declared In
SCDataDefinition.h
objectWithTitle:inObjectsArray:
Returns the object with the given title in objectsArray.
- (NSObject *)objectWithTitle:(NSString *)title inObjectsArray:(NSArray *)objectsArray
Discussion
The title value is determined based on the value of the titlePropertyName property.
Note: All objects must belong to the data structure.
Declared In
SCDataDefinition.h
propertyDataTypeForPropertyWithName:
Returns the property data type of a property given its name.
- (SCDataType)propertyDataTypeForPropertyWithName:(NSString *)propertyName
Declared In
SCDataDefinition.h
propertyDefinitionAtIndex:
Returns the property definition at the given index.
- (SCPropertyDefinition *)propertyDefinitionAtIndex:(NSUInteger)index
Parameters
- index
Must be less than the total number of property definitions.
Declared In
SCDataDefinition.h
propertyDefinitionWithName:
Returns the property definition with the given name.
- (SCPropertyDefinition *)propertyDefinitionWithName:(NSString *)propertyName
Parameters
- propertyName
The name of the property whose definition to be returned.
Declared In
SCDataDefinition.h
removePropertyDefinitionAtIndex:
Removes the property definition at the given index.
- (void)removePropertyDefinitionAtIndex:(NSUInteger)index
Parameters
- index
Must be less than the total number of property definitions.
Declared In
SCDataDefinition.h
removePropertyDefinitionWithName:
Removes the property definition with the given name.
- (void)removePropertyDefinitionWithName:(NSString *)propertyName
Parameters
- propertyName
The name of the property to be removed.
Declared In
SCDataDefinition.h
setupDefaultConfiguration
Sets up default configuration for properties such as keyPropertyName and titlePropertyName.
- (void)setupDefaultConfiguration
Declared In
SCDataDefinition.h
titleValueForObject:
Returns the title string value for the given object.
- (NSString *)titleValueForObject:(NSObject *)object
Discussion
The title value is determined based on the value of the titlePropertyName property.
Note: object must belong to the data structure.
Declared In
SCDataDefinition.h