如何在我的 class 上调用 objectForPrimaryKey

how to invoke objectForPrimaryKey on my class

我有一个 class,其中记录了 primaryKey 的覆盖。

    if let existing = Contact(forPrimaryKey: personR.recordID) {

    }

当我这样做时,编译器说摆脱 "forPrimaryKey" : "Extra argument 'forPrimaryKey' in call"

当我摆脱它时,它认为它是一个 init 然后抱怨说 "Cannot invoke 'init' with an argument of type 'Int32'"

知道如何调用这个方法吗?

if let existing = Contact.objectForPrimaryKey(personR.recordID) {

}

Contact(forPrimaryKey: personR.recordID) 实际上有效 我在 Swift 1.2 和 Xcode 6.3 上工作并且看到了奇怪的行为。

感谢@Segiddins 的帮助