caiyue1993/IceCream

Generic class 'SyncObject' requires that 'String' inherit from 'RealmSwiftObject'

mibrahim025 opened this issue · 1 comments

Hi all, I am using icecream library and want to achieve the following functionality.

In app delegate, I have written

syncEngine = SyncEngine(objects: [
            SyncObject(type: Recipient.self, uListElementType: String.self),
            SyncObject(type: SMSSchedule.self, uListElementType: Recipient.self),
            SyncObject(type: Template.self),
            SyncObject(type: ContactsGroup.self, uListElementType: Recipient.self)
        ])

where Recipient class is...

@objc class Recipient: Object {
    
    @objc dynamic var rec_id = ""
    @objc dynamic var firstName = ""
    @objc dynamic var lastName = ""
    var phoneNumbers = List<String>()
    @objc dynamic var email = ""
    @objc dynamic var colorTag = "#FFFFFFFF"
    @objc dynamic var isDeleted = false  // IceCream requirement
    
    override static func primaryKey() -> String? {
        return "rec_id"
    }

// initialization code

}

Look at the phoneNumbers property. It is a list of string objects. However the SyncObject doesn't accept String as uListElementType. How can I solve this issue?

String is not an object. You only put realm objects as uListElementType.

Actually you don't need to do anything regarding List of supported primitive types ( Int, String etc.)