Count Vs Exists (ARCH9063)
هذا المحتوى غير متوفر بلغتك بعد.
Key swift.orm.count-vs-exists · Severity info · Category orm
Flags context.fetch(request).count / .isEmpty used only to test presence - count(for:) with fetchLimit = 1 stops at the first row.
Incorrect
Section titled “Incorrect”if try context.fetch(request).isEmptyCorrect
Section titled “Correct”request.fetchLimit = 1if try context.count(for: request) == 0Use count(for:) with fetchLimit = 1.