WIP: docs

This commit is contained in:
John Estropia
2020-03-25 14:21:49 +09:00
parent 231e138ab0
commit 0d9299f900
3 changed files with 27 additions and 13 deletions

View File

@@ -34,7 +34,6 @@ extension FieldContainer {
// MARK: - Relationship // MARK: - Relationship
@propertyWrapper @propertyWrapper
// @dynamicMemberLookup
public struct Relationship<V: FieldRelationshipType>: RelationshipKeyPathStringConvertible, FieldRelationshipProtocol { public struct Relationship<V: FieldRelationshipType>: RelationshipKeyPathStringConvertible, FieldRelationshipProtocol {
/** /**

View File

@@ -40,11 +40,8 @@ extension FieldContainer {
@Field.Stored("species") @Field.Stored("species")
var species = "" var species = ""
@Field.Virtual("pluralName", customGetter: Animal.pluralName(_:)) @Field.Stored("nickname")
var pluralName: String = "" var nickname: String?
@Field.Coded("color", coder: FieldCoders.Plist.self)
var color: UIColor?
} }
``` ```
- Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.Stored(...) var` syntax will be ignored. - Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.Stored(...) var` syntax will be ignored.

View File

@@ -32,9 +32,9 @@ import Foundation
extension DynamicObject where Self: CoreStoreObject { extension DynamicObject where Self: CoreStoreObject {
/** /**
The containing type for value propertiess. `Field` properties support any type that conforms to `ImportableAttributeType`. The containing type for value propertiess.
``` ```
class Animal: CoreStoreObject { class Pet: CoreStoreObject {
@Field.Stored("species") @Field.Stored("species")
var species = "" var species = ""
@@ -42,10 +42,19 @@ extension DynamicObject where Self: CoreStoreObject {
var nickname: String? var nickname: String?
@Field.Coded("color", coder: FieldCoders.Plist.self) @Field.Coded("color", coder: FieldCoders.Plist.self)
var color: UIColor? var eyeColor: UIColor?
@Field.Relationship("owner", inverse: \.$pets)
var owner: Person?
@Field.Relationship("children")
var children: Array<Pet>
@Field.Relationship("parents", inverse: \.$children)
var parents: Set<Pet>
} }
``` ```
- Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.*(...) var` syntax will be ignored. - Important: `Field` properties are required to be used as `@propertyWrapper`s. Any other declaration not using the `@Field.*(...) var` syntax will result in undefined behavior.
*/ */
public typealias Field = FieldContainer<Self> public typealias Field = FieldContainer<Self>
} }
@@ -54,9 +63,9 @@ extension DynamicObject where Self: CoreStoreObject {
// MARK: - FieldContainer // MARK: - FieldContainer
/** /**
The containing type for value properties. Use the `DynamicObject.Field` typealias instead for shorter syntax. The containing type for value properties. Use the `Field` typealias instead for shorter syntax.
``` ```
class Animal: CoreStoreObject { class Pet: CoreStoreObject {
@Field.Stored("species") @Field.Stored("species")
var species = "" var species = ""
@@ -64,7 +73,16 @@ extension DynamicObject where Self: CoreStoreObject {
var nickname: String? var nickname: String?
@Field.Coded("color", coder: FieldCoders.Plist.self) @Field.Coded("color", coder: FieldCoders.Plist.self)
var color: UIColor? var eyeColor: UIColor?
@Field.Relationship("owner", inverse: \.$pets)
var owner: Person?
@Field.Relationship("children")
var children: Array<Pet>
@Field.Relationship("parents", inverse: \.$children)
var parents: Set<Pet>
} }
``` ```
*/ */