Diffusion Apple API  6.7.4
Unified Client Library for iOS, tvOS and OS X / macOS
 All Classes Files Functions Variables Enumerations Enumerator Properties Pages
Instance Methods | List of all members
PTDiffusionRecordV2Model Class Reference

Introduction

A data model based upon a schema.

A read only model can be created from any PTDiffusionRecordV2 object using the PTDiffusionRecordV2::modelWithSchema: method. The model then provides direct access to the fields within the data. Fields may be accessed either by explicitly specifying the record and field occurrence or by specifying a key of the form:

recordName(recordIndex).fieldName(fieldIndex)

Indexes start from 0 and if omitted then 0 is assumed. The record name may also be omitted, in which case the first record definition. This form of addressing is useful when there is only one record definition.

Examples of valid keys include:

Key Meaning
Address(4).AddressLine(3) The 4th AddressLine occurrence within the 5th Address record.
Address.Name The first (or only) Name field within the first (or only) Address record.
AddressLine(1) The 2nd AddressLine field within the first (or only) record.
Name The first (or only) Name field within the first (or only) record.

The recordCountWithRecordName:error: (PTDiffusionRecordV2Model) and fieldCountWithRecordName:recordIndex:fieldName:error: (PTDiffusionRecordV2Model) methods are useful for determining the actual number of occurrences of variable multiplicity items.

Since
6.0
Inheritance diagram for PTDiffusionRecordV2Model:
PTDiffusionMutableRecordV2Model

Instance Methods

(nullable PTDiffusionRecordV2 *) - valueWithError:
 
(nullable NSNumber *) - fieldCountWithRecordName:recordIndex:fieldName:error:
 
(nullable NSNumber *) - recordCountWithRecordName:error:
 
(nullable NSString *) - fieldValueForKey:error:
 
(nullable NSString *) - fieldValueForRecordName:recordIndex:fieldName:fieldIndex:error:
 

Method Documentation

- (nullable NSNumber *) fieldCountWithRecordName: (NSString *)  recordName
recordIndex: (SInt32)  recordIndex
fieldName: (NSString *)  fieldName
error: (NSError **)  error 

Returns the actual number of occurrences of a named field within a specified record occurrence.

For all but variable fields this returns the schema defined number of occurrences of the field.

Parameters
recordNameThe record name.
recordIndexThe record index.
fieldNameThe field name.
errorIf this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure.
Returns
The actual number of occurrences of the field as an unsigned integer; or nil if an error occurred, in which case *error will be populated with the failure reason. Reasons for failure include:
  • either recordName or fieldName are not defined in the schema.
  • recordIndex is out of bounds.
Exceptions
NSInvalidArgumentExceptionIf either recordName or fieldName is nil, or if recordIndex is negative.
Since
6.0
- (nullable NSString *) fieldValueForKey: (NSString *)  key
error: (NSError **)  error 

Get a field value.

This allows an item to be addressed using a key of the form recordName(recordIndex).fieldName(fieldIndex). Indexes may be omitted in which case 0 is assumed. The record part may also be omitted in which case the first occurrence of the first record is assumed.

Parameters
keyThe field key.
errorIf this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure.
Returns
The field value; or nil if an error occurred, in which case *error will be populated with the failure reason. Reasons for failure include:
  • the key does not address a valid field.
  • an index is out of bounds.
  • the key format is invalid.
  • an index is not a valid number.
Exceptions
NSInvalidArgumentExceptionIf key is nil.
Since
6.0
- (nullable NSString *) fieldValueForRecordName: (NSString *)  recordName
recordIndex: (SInt32)  recordIndex
fieldName: (NSString *)  fieldName
fieldIndex: (SInt32)  fieldIndex
error: (NSError **)  error 

Get a field value.

Parameters
recordNameThe name of the record.
recordIndexthe index of the record.
fieldNameThe name of the field.
fieldIndexThe index of the field.
errorIf this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure.
Returns
The field value; or nil if an error occurred, in which case *error will be populated with the failure reason. Reasons for failure include:
  • either recordName or fieldName are not defined in the schema.
  • either recordIndex or fieldIndex is out of bounds.
Exceptions
NSInvalidArgumentExceptionIf either recordName or fieldName is nil, recordIndex is negative or fieldIndex is negative.
Since
6.0
- (nullable NSNumber *) recordCountWithRecordName: (NSString *)  recordName
error: (NSError **)  error 

Returns the actual number of occurrences of a named record.

If the record is not variable, this is the same as the defined number of occurrences in the schema.

Parameters
recordNameThe record name.
errorIf this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure.
Returns
The actual number of occurrences of the record as an unsigned integer; or nil if an error occurred, in which case *error will be populated with the failure reason. Reasons for failure include:
  • recordName is not defined in the schema.
Exceptions
NSInvalidArgumentExceptionIf recordName is nil.
Since
6.0
- (nullable PTDiffusionRecordV2 *) valueWithError: (NSError **)  error

Returns an immutable record instance generated from this model; or nil if an error occurred, in which case *error will be populated with the failure reason.

Parameters
errorIf this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure.
Returns
Immutable record instance generated from this model.
Since
6.0