I am using realm in my iOS app. In my app, I have made an object file in which, there are some string variables and I have one array also in it. This is my Object class for realm,
class Reminder: Object {
@objc dynamic var name = ""
@objc dynamic var done = false
@objc dynamic var namesArray = [String]()
}
Now in my VC, I am passing an array to the namesArray of my Object class.
let names : [String] = ["Ali","Hammad","Hamza"]
let textFieldReminder = (alertVC.textFields?.first)! as UITextField
let reminderItem = Reminder() // (8)
reminderItem.name = textFieldReminder.text!
reminderItem.done = false
reminderItem.namesArray = names
// We are adding the reminder to our database
try! self.realm.write({
self.realm.add(reminderItem)
Now when I run the app, the application crashes with this error messages,
Terminating app due to uncaught exception 'RLMException', reason: 'Property 'namesArray' is declared as 'NSArray', which is not asupported RLMObject property type. All properties must be primitives, NSString, NSDate, NSData, NSNumber, RLMArray, RLMLinkingObjects, or subclasses of RLMObject. See https://realm.io/docs/objc/latest/api/Classes/RLMObject.html for more information.'
How can i store array of string in my realm db?