DACalculatedFieldDefinition

Overview

DACalculatedFieldDefinition is a specialization of the general DAFieldDefinition class, and represents a field for which the value is not stored directly in the DADataTable, but calculated, at runtime. In contrast to DALookupFieldDefinitions, which obtain their value automatically by referring to another table, calculated fields depend on the developer to provide custom code that determines the value of the field, as needed. For this, a selector and a target object are assigned to the calculated field, with the selector identifying the name of the custom method that provides the implementation, and the target identifying the object that implements this selector.

The calculation method must be defined to take one parameter, a DADataTableRow, and return id or an object matching the dataType configured for the field. When called, the row parameter will provide access to the row that the value should be calculated for. No reference to the calculated field is provided, so a class that is meant to provide values for multiple calculated fields will need to provide distinct methods for each.

DACalculatedFieldDefinitions can be created either by calling addCalculatedFieldName:dataType:target:selector: on the DADataTable, or by manually creating an instance and passing it to addCalculatedField:.

Calculated fields can be seen in action in the Field Types sample.

Location


 

attributeType    (declared in DAFieldDefinition)

- (NSAttributeType) attributeType

autoIncrement    (declared in DAFieldDefinition)

- (BOOL) autoIncrement

dataType    (declared in DAFieldDefinition)

Specifies the Data Type for the field.

@property (readonly) enum DADataType dataType

dataTypeName    (declared in DAFieldDefinition)

Returns the readable name of the fields data type, as defined by the dataType property.

@property (readonly) NSString *dataTypeName

initWithDataTable:name:dataType:target:selector:

- (InstanceType) initWithDataTable:(DADataTable *)ownerTable name:(NSString *)fieldName dataType:(enum DADataType)dataType target:(id)target selector:(SEL)selector

Parameters:

  • ownerTable:
  • fieldName:
  • dataType:
  • target:
  • selector:

initWithTable:    (declared in DAFieldDefinition)

- (InstanceType) initWithTable:(DADataTable *)ownerTable

Parameters:

  • ownerTable:

initWithTable:andSchema:    (declared in DAFieldDefinition)

- (InstanceType) initWithTable:(DADataTable *)ownerTable andSchema:(DASchemaDataTableField *)schemaField

Parameters:

  • ownerTable:
  • schemaField:

initWithTable:name:    (declared in DAFieldDefinition)

- (InstanceType) initWithTable:(DADataTable *)ownerTable name:(NSString *)fieldName

Parameters:

  • ownerTable:
  • fieldName:

name    (declared in DAFieldDefinition)

Specifies the uniqe name of the field within the data table. The field can be queried by this name using KVC's valueForKey: and setValue:forKey: methods on the individual DADataTableRows.

@property (readonly) NSString *name

position    (declared in DAFieldDefinition)

Returns the position or index of the field within the data table. This is mainly for internal use; regular field access should use the name and not rely on position.

@property (readonly) NSInteger position

predicateEditorRowTemplateForName:type:    (declared in DAFieldDefinition)

+ (NSPredicateEditorRowTemplate *) predicateEditorRowTemplateForName:(NSString *)name type:(NSAttributeType)type

Parameters:

  • name:
  • type:

predicateEditorRowTemplates    (declared in DAFieldDefinition)

Returns an array with one or more NSPredicateEditorRowTemplates that match the field definition, for use in an NSPredicateEditor. Usually, you will not call 'send this message' to an individual field, but use the DADataTable's defaultPredicateEditorRowTemplates method. See also Working with NSPredicateEditor (Xcode).

- (NSArray *) predicateEditorRowTemplates

predicateEditorRowTemplateStandardOperators    (declared in DAFieldDefinition)

+ (NSArray *) predicateEditorRowTemplateStandardOperators

properties    (declared in DAFieldDefinition)

Provides access to various properties of the field as defined in the server's Schema.

@property (readonly) NSDictionary *properties

selector

Specifies the object that implements the calculation method identified by the selector.

@property (readonly) SEL selector

setDataType:    (declared in DAFieldDefinition)

- (void) setDataType:(enum DADataType)aType

Parameters:

  • aType:

setPosition:    (declared in DAFieldDefinition)

- (void) setPosition:(NSInteger)aPosition

Parameters:

  • aPosition:

setProperty:toValue:    (declared in DAFieldDefinition)

Updates a property stored in the properties list.

- (void) setProperty:(NSString *)propertyName toValue:(NSString *)propertyValue

Parameters:

  • propertyName: name of the property for which we want to set new value
  • propertyValue: new value we want to set.

table    (declared in DAFieldDefinition)

Returns a reference to the DADataTable that contains this field.

@property (readonly) DADataTable *table

target

Specifies the selector identifying the method on the target that will calculate the value for this field.

@property (readonly) id target

valueForRow:

For internal use, returns the calculated value for a given row, by performing the selector on the target.

- (id) valueForRow:(DADataTableRow *)row

Parameters:

  • row: Row to calculate the value for.

visible  assign    (declared in DAFieldDefinition)

Specifies whether this field should be visible in user interfaces. This property is not used directly by the Data Abstract framework, but can be queried by user interface code to determine whether to see the field (for example in a table view or a field picker) or not. visible will be initialized based on the value set in the Schema, server-side, but can be changed within the client, if necessary.

@property (assign) BOOL visible

 

dataType    (declared in DAFieldDefinition)

Specifies the Data Type for the field.

@property (readonly) enum DADataType dataType

dataTypeName    (declared in DAFieldDefinition)

Returns the readable name of the fields data type, as defined by the dataType property.

@property (readonly) NSString *dataTypeName

name    (declared in DAFieldDefinition)

Specifies the uniqe name of the field within the data table. The field can be queried by this name using KVC's valueForKey: and setValue:forKey: methods on the individual DADataTableRows.

@property (readonly) NSString *name

position    (declared in DAFieldDefinition)

Returns the position or index of the field within the data table. This is mainly for internal use; regular field access should use the name and not rely on position.

@property (readonly) NSInteger position

properties    (declared in DAFieldDefinition)

Provides access to various properties of the field as defined in the server's Schema.

@property (readonly) NSDictionary *properties

selector

Specifies the object that implements the calculation method identified by the selector.

@property (readonly) SEL selector

table    (declared in DAFieldDefinition)

Returns a reference to the DADataTable that contains this field.

@property (readonly) DADataTable *table

target

Specifies the selector identifying the method on the target that will calculate the value for this field.

@property (readonly) id target

visible  assign    (declared in DAFieldDefinition)

Specifies whether this field should be visible in user interfaces. This property is not used directly by the Data Abstract framework, but can be queried by user interface code to determine whether to see the field (for example in a table view or a field picker) or not. visible will be initialized based on the value set in the Schema, server-side, but can be changed within the client, if necessary.

@property (assign) BOOL visible

 

predicateEditorRowTemplateForName:type:    (declared in DAFieldDefinition)

+ (NSPredicateEditorRowTemplate *) predicateEditorRowTemplateForName:(NSString *)name type:(NSAttributeType)type

Parameters:

  • name:
  • type:

predicateEditorRowTemplateStandardOperators    (declared in DAFieldDefinition)

+ (NSArray *) predicateEditorRowTemplateStandardOperators

 

attributeType    (declared in DAFieldDefinition)

- (NSAttributeType) attributeType

autoIncrement    (declared in DAFieldDefinition)

- (BOOL) autoIncrement

initWithDataTable:name:dataType:target:selector:

- (InstanceType) initWithDataTable:(DADataTable *)ownerTable name:(NSString *)fieldName dataType:(enum DADataType)dataType target:(id)target selector:(SEL)selector

Parameters:

  • ownerTable:
  • fieldName:
  • dataType:
  • target:
  • selector:

initWithTable:    (declared in DAFieldDefinition)

- (InstanceType) initWithTable:(DADataTable *)ownerTable

Parameters:

  • ownerTable:

initWithTable:andSchema:    (declared in DAFieldDefinition)

- (InstanceType) initWithTable:(DADataTable *)ownerTable andSchema:(DASchemaDataTableField *)schemaField

Parameters:

  • ownerTable:
  • schemaField:

initWithTable:name:    (declared in DAFieldDefinition)

- (InstanceType) initWithTable:(DADataTable *)ownerTable name:(NSString *)fieldName

Parameters:

  • ownerTable:
  • fieldName:

predicateEditorRowTemplates    (declared in DAFieldDefinition)

Returns an array with one or more NSPredicateEditorRowTemplates that match the field definition, for use in an NSPredicateEditor. Usually, you will not call 'send this message' to an individual field, but use the DADataTable's defaultPredicateEditorRowTemplates method. See also Working with NSPredicateEditor (Xcode).

- (NSArray *) predicateEditorRowTemplates

setDataType:    (declared in DAFieldDefinition)

- (void) setDataType:(enum DADataType)aType

Parameters:

  • aType:

setPosition:    (declared in DAFieldDefinition)

- (void) setPosition:(NSInteger)aPosition

Parameters:

  • aPosition:

setProperty:toValue:    (declared in DAFieldDefinition)

Updates a property stored in the properties list.

- (void) setProperty:(NSString *)propertyName toValue:(NSString *)propertyValue

Parameters:

  • propertyName: name of the property for which we want to set new value
  • propertyValue: new value we want to set.

valueForRow:

For internal use, returns the calculated value for a given row, by performing the selector on the target.

- (id) valueForRow:(DADataTableRow *)row

Parameters:

  • row: Row to calculate the value for.