A type that describes the user interface presentation of a custom type.
Members (9)
get · iOS 16.0+
numericFormat
TypeScript
get numericFormat(): (_Foundation_LocalizedStringResource) | null
Swift declaration
var numericFormat: LocalizedStringResource?
A string representing a count for the type, e.g. "2 books".
In your `numericFormat` implementation, use `StringInterpolation` placeholders and provide a
`.stringsdict` file with all possible pluralizations for the type, such as "0 books", "1 book",
and "2 books".
Example:
```
TypeDisplayRepresentation(
name: LocalizedStringResource("Book"),
numericFormat: LocalizedStringResource("\(placeholder: .int) books")
)
```
```
<dict>
<key>Book</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@VARIABLE@</string>
<key>VARIABLE</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>one</key>
<string>Book</string>
<key>other</key>
<string>Books</string>
</dict>
</dict>
<key>%lld books</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@count@</string>
<key>count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>%lld books</string>
<key>one</key>
<string>%lld book</string>
<key>other</key>
<string>%lld books</string>
</dict>
</dict>
</dict>
```
set · iOS 16.0+
numericFormat
TypeScript
set numericFormat(value: (_Foundation_LocalizedStringResource) | null)
Swift declaration
var numericFormat: LocalizedStringResource?
A string representing a count for the type, e.g. "2 books".
In your `numericFormat` implementation, use `StringInterpolation` placeholders and provide a
`.stringsdict` file with all possible pluralizations for the type, such as "0 books", "1 book",
and "2 books".
Example:
```
TypeDisplayRepresentation(
name: LocalizedStringResource("Book"),
numericFormat: LocalizedStringResource("\(placeholder: .int) books")
)
```
```
<dict>
<key>Book</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@VARIABLE@</string>
<key>VARIABLE</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>one</key>
<string>Book</string>
<key>other</key>
<string>Books</string>
</dict>
</dict>
<key>%lld books</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@count@</string>
<key>count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>%lld books</string>
<key>one</key>
<string>%lld book</string>
<key>other</key>
<string>%lld books</string>
</dict>
</dict>
</dict>
```
get synonyms(): Array<_Foundation_LocalizedStringResource>
Swift declaration
var synonyms: [LocalizedStringResource]
A list of localized phrases that are synonyms of this particular type display representation
Example:
```
struct PizzaEntity: AppEntity {
static var typeDisplayRepresentation = TypeDisplayRepresentation(
name: "Pizza",
synonyms: ["Pie", "Za"]
)
}
```
In this case, we are saying that PizzaEntity can be represented as "Pizza", "Pie" or "Za"
set · iOS 17.0+
synonyms
TypeScript
set synonyms(value: Array<_Foundation_LocalizedStringResource>)
Swift declaration
var synonyms: [LocalizedStringResource]
A list of localized phrases that are synonyms of this particular type display representation
Example:
```
struct PizzaEntity: AppEntity {
static var typeDisplayRepresentation = TypeDisplayRepresentation(
name: "Pizza",
synonyms: ["Pie", "Za"]
)
}
```
In this case, we are saying that PizzaEntity can be represented as "Pizza", "Pie" or "Za"