{"action":"opened","issue":{"url":"https://api.github.com/repos/Alecrim/AlecrimCoreData/issues/50","labels_url":"https://api.github.com/repos/Alecrim/AlecrimCoreData/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/Alecrim/AlecrimCoreData/issues/50/comments","events_url":"https://api.github.com/repos/Alecrim/AlecrimCoreData/issues/50/events","html_url":"https://github.com/Alecrim/AlecrimCoreData/issues/50","id":82479906,"number":50,"title":"How to filter an existing FetchedResultsController?","user":{"login":"basememara","id":892152,"avatar_url":"https://avatars.githubusercontent.com/u/892152?v=3","gravatar_id":"","url":"https://api.github.com/users/basememara","html_url":"https://github.com/basememara","followers_url":"https://api.github.com/users/basememara/followers","following_url":"https://api.github.com/users/basememara/following{/other_user}","gists_url":"https://api.github.com/users/basememara/gists{/gist_id}","starred_url":"https://api.github.com/users/basememara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basememara/subscriptions","organizations_url":"https://api.github.com/users/basememara/orgs","repos_url":"https://api.github.com/users/basememara/repos","events_url":"https://api.github.com/users/basememara/events{/privacy}","received_events_url":"https://api.github.com/users/basememara/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-29T15:47:29Z","updated_at":"2015-05-29T15:47:29Z","closed_at":null,"body":"Great library, clean and simple API!!\r\n\r\nI am following the `MasterViewController` example that is using `FetchedResultsController` which is really nice. I see that it refreshes the `tableview` automatically on creates, updates, and deletes. However, I have a search bar in my navigation. How can I apply a search/filter on the current `FetchedResultsController` instance?\r\n\r\nThis is the variable I am referring to in `MasterViewController`:\r\n```\r\n    lazy var fetchedResultsController: FetchedResultsController<BlogPostEntity> = {\r\n        let frc = self.dataContext.blogPosts.orderByDescending({ $0.publicationDate }).toFetchedResultsController()\r\n        frc.bindToCollectionView(self.currentCollection)\r\n        return frc\r\n    }()\r\n```\r\n\r\nThen in my search button click, what do I do? I can filter the entities like this: `fetchedResultsController.entities.filter`, but this is not using Core Data but searching the entities in place. Or should I overwrite the `fetchedResultsController` variable with a new variable that has the filter like this?:\r\n\r\n```\r\n    func searchBarSearchButtonClicked(searchBar: UISearchBar) {\r\n        if !searchBar.text.isEmpty {\r\n            fetchedResultsController = {\r\n                let frc = self.dataContext.blogPosts.filter({ $0.title == searchBar.text }).toFetchedResultsController()\r\n                frc.bindToCollectionView(self.currentCollection)\r\n                return frc\r\n            }()\r\n        }\r\n    }\r\n```\r\n\r\nThis seems inefficient and problematic. Any proper or built-in way to filter an existing `FetchedResultsController`?\r\n"}}