![]() |
Diffusion Apple API 6.11.5
Unified Client Library for iOS, tvOS and OS X / macOS
|
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.
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: |
- (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.
recordName | The record name. |
recordIndex | The record index. |
fieldName | The field name. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
nil
if an error occurred, in which case *error
will be populated with the failure reason. Reasons for failure include:recordName
or fieldName
are not defined in the schema.recordIndex
is out of bounds.NSInvalidArgumentException | If either recordName or fieldName is nil , or if recordIndex is negative. |
- (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.
key | The field key. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
nil
if an error occurred, in which case *error
will be populated with the failure reason. Reasons for failure include:NSInvalidArgumentException | If key is `nil`. |
- (nullable NSString *) fieldValueForRecordName: | (NSString *) | recordName | |
recordIndex: | (SInt32) | recordIndex | |
fieldName: | (NSString *) | fieldName | |
fieldIndex: | (SInt32) | fieldIndex | |
error: | (NSError **) | error | |
Get a field value.
recordName | The name of the record. |
recordIndex | the index of the record. |
fieldName | The name of the field. |
fieldIndex | The index of the field. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
nil
if an error occurred, in which case *error
will be populated with the failure reason. Reasons for failure include:recordName
or fieldName
are not defined in the schema.recordIndex
or fieldIndex
is out of bounds.NSInvalidArgumentException | If either recordName or fieldName is nil , recordIndex is negative or fieldIndex is negative. |
- (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.
recordName | The record name. |
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |
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.NSInvalidArgumentException | If recordName is `nil`. |
- (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.
error | If this method returns nil to indicate that an error occurred then this will be populated with the reason for that failure. |