Context
I have a Core Data entity called 'Task'
'Task' has a relationship with another entity called 'Tag' : @NSManaged public var tags: NSSet?
This data is stored as:
public var tagsArray: [Tag] {
let set = tags as? Set<Tag> ?? []
return set.sorted {
$0.wrappedTagTitle < $1.wrappedTagTitle
}
}
I am trying to filter a list of tasks on the basis if they contain a certain tag, i.e. with a title of "School".
var fetchRequest: FetchRequest<Task>
init(tagFilterName: String) {
let tag = Tag()
tag.title = tagFilterName
fetchRequest = FetchRequest<Task>(entity: Task.entity(), sortDescriptors: [], predicate: NSPredicate(format: "tagsArray CONTAINS %@", tag))
}
This is initialised in the parent view:
FilteredScrollView(tagFilterName: "School")
(Excuse the haphazard code in the init, I am just trying to get across what I am trying to do.)
Result
As it stands this crashes on runtime. Any help would be greatly appreciated.