CoreValue
CoreValue copied to clipboard
Cannot invoke 'curry' with an argument list of type '((objectID: NSManagedObjectID?, name: String, employees: Array<StoredEmployee>) -> StoredCompany)
We have next two separated files:
// StoredCompany.swift
import CoreData
import CoreValue
struct StoredCompany: CVManagedPersistentStruct {
static let EntityName = "Company"
var objectID: NSManagedObjectID?
var name: String
var employees: Array<StoredEmployee>
static func fromObject(o: NSManagedObject) throws -> StoredCompany {
return try curry(self.init)
<^> o <|? "objectID"
<^> o <| "name"
<^> o <|| "employees"
}
mutating func save(context: NSManagedObjectContext) throws {
try employees.saveAll(context)
try defaultSave(context)
}
// StoredEmployee.swift
import CoreData
import CoreValue
struct StoredEmployee : CVManagedPersistentStruct {
static let EntityName = "Employee"
var objectID: NSManagedObjectID?
let name: String
let age: Int16
let position: String?
let department: String
let job: String
static func fromObject(o: NSManagedObject) throws -> StoredEmployee {
return try curry(self.init)
<^> o <|? "objectID"
<^> o <| "name"
<^> o <| "age"
<^> o <|? "position"
<^> o <| "department"
<^> o <| "job"
}
}
The compiler throws next error .../StoredCompany.swift:21:20: Cannot invoke 'curry' with an argument list of type '((objectID: NSManagedObjectID?, name: String, employees: Array<StoredEmployee>) -> StoredCompany)'
It's happens only when struct StoredEmployee
and struct StoredCompany
are in separated files. Probably that's the reason that the tests doesn't catch it.
Cheers! 🍻
Does your project have multiple targets? Is it possible that you did not add both files to all appropriate targets when you separated them?
Does this still happen? If yes, can you try with the current Swift 3 release (CoreValue 0.2)?
Though not sure why it was happening, adding:
typealias StructureType = StoredEmployee
usually solved the problem for me.
I bumped into the same issue. this solved it too:
typealias StructureType = MyStructureType
btw, is this project alive?