예상

@propertyWrapper
public struct Projected<T, Value> : AnyProjected where T : RLMObjectBase

@Projected Realm에서 managed해야 하는 Projection 프로토콜의 속성을 선언하는 데 사용됩니다.

사용 예시:

public class Person: Object {
    @Persisted var firstName = ""
    @Persisted var lastName = ""
    @Persisted var address: Address?
    @Persisted var friends: List<Person>
    @Persisted var reviews: List<String>
}

class PersonProjection: Projection<Person> {
    @Projected(\Person.firstName) var firstName
    @Projected(\Person.lastName.localizedUppercase) var lastNameCaps
    @Projected(\Person.address.city) var homeCity
    @Projected(\Person.friends.projectTo.firstName) var firstFriendsName: ProjectedCollection<String>
}

let people: Results<PersonProjection> = realm.objects(PersonProjection.self)
  • 유형의 기본값으로 느리게 초기화되는 속성을 선언합니다.

    선언

    Swift

    public init(_ projectedKeyPath: KeyPath<T, Value>)