Appending list objects to realm swift


cannot append all objects to list in realm model .out of 12 objects only 4 are getting appended to realm db


Can you show a sample of the code you use to append the objects to the List?

Are you using List.Append() (


if(!(response[“branchProducts”] is NSNull)){
for bpDict in response[“branchProducts”] as! [Any]{
let bpr = bpDict as![String:Any]
var bp = RealmBranchProduct()
bp = self.branchProductParser(response: bpr)
if(!(self.branchProducts.contains(where: {$ ==}))){

above is the code that i use for parsing response from api to realm model .
the line ‘‘self.branchProducts.append(bp)’’ is not appending all objects . at the time of creating realm model .However when i added the object “bp” to realm before appending to list “self.branchProducts” its working i.e

try! Constants.realm.write {
Constants.realm.add(bp, update: true)

.It sounds weird . same kind of issue appears everywhere .it would be helpful if you can provide me an exact approach to append list objects while adding model to realm