schmru
schmru

Reputation: 619

Add object to RLMArray

I am trying to create rlmobject with rlmarray as one of elemnts but cant get it to work.

declaration:

 dynamic var contactInfo : RLMArray = RLMArray(objectClassName: "ContactInfoDB")

and insertion:

tempLocation.contactInfo.addObject(tc)

where tc is

class ContactInfoDB: RLMObject

but somehow after add the array is still empty. Is there eny other way to insert object into rlmarray with swift using realm for objective c, because I need it to work also in iOS7.

Thank you for any help.

Upvotes: 1

Views: 1565

Answers (1)

scollaco
scollaco

Reputation: 922

I've been used Realm for Objective-C, but it should be the same. To make any changes on your db, you should follow the steps:

realm.beginWriteTransaction()

// Do what you have to do with your Realm objects

realm.commitWriteTransaction()

This link can help you : How to use RLMArray to save an Array

Upvotes: 5

Related Questions