Skip to content

Commit

Permalink
Merge pull request #359 from warrenburton/swift3
Browse files Browse the repository at this point in the history
[FIX] Swift: fetchOneThing compilation. [Warren Burton](#359)
  • Loading branch information
rentzsch committed Dec 30, 2016
2 parents fdafd42 + 3b0c3fb commit 9e403ad
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions templates/machine.swift.motemplate
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ open class _<$sanitizedManagedObjectClassName$>: NSManagedObject {
class func fetch<$FetchRequest.name.initialCapitalString$>(managedObjectContext: NSManagedObjectContext<$foreach Binding FetchRequest.bindings do2$>, <$Binding.name$>: <$Binding.type$><$endforeach do2$>, error outError: NSErrorPointer) -> Any? {
guard let psc = managedObjectContext.persistentStoreCoordinator else { return nil }
let model = psc.managedObjectModel
let substitutionVariables = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$>
"<$Binding.name$>": <$Binding.name$>,
<$endforeach do2$><$endif$>
]
let substitutionVariables : [String : Any] = [<$if FetchRequest.hasBindings$><$foreach Binding FetchRequest.bindings do2$>
"<$Binding.name$>": <$Binding.name$>,
<$endforeach do2$><$else$>:<$endif$>]

guard let fetchRequest = model.fetchRequestFromTemplate(withName: "<$FetchRequest.name$>", substitutionVariables: substitutionVariables) else {
assert(false, "Can't find fetch request named \"<$FetchRequest.name$>\".")
Expand Down

0 comments on commit 9e403ad

Please sign in to comment.