Insert Loop Without Batch (ARCH9053)
Esta página aún no está disponible en tu idioma.
Key swift.orm.insert-loop-without-batch · Severity warning · Category orm
Flags NSEntityDescription.insertNewObject / realm.add inside a loop - one managed object per row where NSBatchInsertRequest exists.
Incorrect
Section titled “Incorrect”for row in rows { NSEntityDescription.insertNewObject(forEntityName: "Order", into: context) }Correct
Section titled “Correct”let batch = NSBatchInsertRequest(entityName: "Order", objects: rows)Use NSBatchInsertRequest (Core Data) or realm.add(objects) in one write.