Skip to content

Instantly share code, notes, and snippets.

@nikolsky2
Last active July 19, 2016 01:32
Show Gist options
  • Save nikolsky2/defacbc998d92538117c8f862a195e12 to your computer and use it in GitHub Desktop.
Save nikolsky2/defacbc998d92538117c8f862a195e12 to your computer and use it in GitHub Desktop.
NSFetchRequest fetch properties only
let searchTermPropertyName = "term"
let searchFetchRequest = NSFetchRequest(entityName: SearchEntity.className)
searchFetchRequest.propertiesToFetch = [searchTermPropertyName]
searchFetchRequest.resultType = .DictionaryResultType
let allSearches = try! privateContext.executeFetchRequest(searchFetchRequest) as! [[String: String]]
let allSearchTerms = allSearches.flatMap {$0[searchTermPropertyName]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment