# Predicate to filter against array of items

**URL:** <https://forums.swift.org/t/predicate-to-filter-against-array-of-items/70986>\
**Category:** Using Swift\
**Tags:** swiftdata, predicate\
**Created:** [March 30, 2024, 12:37pm UTC](https://forums.swift.org/t/predicate-to-filter-against-array-of-items/70986 "2024-03-30T12:37:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jmschonfeld](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jmschonfeld/32/20922_2.png) [@jmschonfeld](https://forums.swift.org/u/jmschonfeld)\
**Post date:** [April 1, 2024, 4:10pm UTC](https://forums.swift.org/t/predicate-to-filter-against-array-of-items/70986/2 "2024-04-01T16:10:33Z")

</div>

Since `Predicate` is both `Codable` and `Sendable`, it requires that everything the predicate captures (i.e. all instances captured by the closure) are also `Codable` and `Sendable`. In your case, your predicate is capturing `tags` which has the type `[Tag]`, and it looks like from the declaration of `Tag` that it is neither `Codable` nor `Sendable`, which is likely what the compiler is trying to tell you here.

To resolve this, can you capture the list of UUIDs instead (since `UUID` is `Codable & Sendable`)? For example:

```swift
let tags: [Tag] = ...
let uuids = tags.map(\.uuid)
#Predicate<Place> { place in
  place.tags.allSatisfy { tag in
    uuids.contains(tag.uuid)
  }
}

```

---

_[View the full topic](https://forums.swift.org/t/predicate-to-filter-against-array-of-items/70986)._
