Zum Inhalt springen

Insert Loop Without Batch (ARCH9053)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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.

for row in rows { NSEntityDescription.insertNewObject(forEntityName: "Order", into: context) }
let batch = NSBatchInsertRequest(entityName: "Order", objects: rows)

Use NSBatchInsertRequest (Core Data) or realm.add(objects) in one write.