'Realm can not access property which is not defined @Persisted

I am new in Realm swift, I have the class like this:

class LinkInfo : Object{
    @Persisted var VxLinkType : Int = 0
    @Persisted var Title : String?
    @Persisted var Color : String
    @Persisted var BackgroundColor : String?
    var CustomLinearColor : RoomTitleLinearColor?

because CustomLinearColor contain CGPoint, Color and CGFloat so i decide to using it as dynamic property and not save in Realm.

class RoomTitleLinearColor : NSObject{
    var points : (CGPoint, CGPoint)
    var colors : [UIColor]
    var locations : [CGFloat]

When class LinkInfo have BackgroundColor color, i using it to set CustomLinearColor( then set it successfully)

But when get CustomLinearColor, it return nil, when using debugger i saw:

(lldb) po refreshingInfo.linkInfo
▿ Optional<LinkInfo>
  ▿ some : LinkInfo {
    VxLinkType = 2000;
    Title = (null);
    Color = #f202fa;
    BackgroundColor = linear-gradient( 0deg , rgba(248,254,11,1) 0%, rgba(233,56,56,1) 87%);;
}

I am sure the CustomLinearColor have value, but can not access it, can anyone help me to solved this? Thanks in advance

UPDATE: I know the CustomLinearColor is IgnoredProperty in Realm, and I have to manage it's lifetime. But please see the code below, i get the LinkInfo's JSON, and convert it to LinkInfo type

init(dict : NSDictionary) {

        VxLinkType = dict["VxLinkType"] as? Int ?? dict["vxLinkType"] as? Int ?? 0
        Title = dict["Title"] as? String ?? dict["title"] as? String
        Color = dict["Color"] as? String ?? DARK_GREEN_COLOR
        BackgroundColor = dict["BackgroundColor"] as? String
        if let BackgroundColor = self.BackgroundColor{

       -> set CustomLinearColor

So I think the CustomLinearColor still alive, not destroyed, because Im checked it right after convert Json => LinkInfo class. But when print object it's does not provide CustomLinearColor



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source