Swift 如何在我的类上调用objectForPrimaryKey

Swift 如何在我的类上调用objectForPrimaryKey,swift,realm,Swift,Realm,我有一个类,它对primaryKey进行了重写,如文档所示 if let existing = Contact(forPrimaryKey: personR.recordID) { } 当我这样做时,编译器会说去掉“forPrimaryKey”: “调用中的额外参数'forPrimaryKey'” 当我把它处理掉的时候,它会把它当作init,然后抱怨说 “无法使用'Int32'类型的参数调用'init'” 知道如何调用此方法吗?联系人(forPrimaryKey:person

我有一个类,它对primaryKey进行了重写,如文档所示

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

    }
当我这样做时,编译器会说去掉“forPrimaryKey”: “调用中的额外参数'forPrimaryKey'”

当我把它处理掉的时候,它会把它当作init,然后抱怨说 “无法使用'Int32'类型的参数调用'init'”

知道如何调用此方法吗?

联系人(forPrimaryKey:personR.recordID)实际上可以工作我在Xcode 6.3上开发Swift 1.2,看到了奇怪的行为

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

}

感谢@Segiddins的帮助

这实际上是一个错误。错误:“objectForPrimaryKey”不可用:使用对象构造“RLMObject(forPrimaryKey:)”联系。objectForPrimaryKey(recordID)^~~~~~~~~~~~~~~~~~~~~~领域。RLMObject:258:42:注意:“objectForPrimaryKey”已在这里显式标记为不可用@objectForPrimaryKey:)类func objectForPrimaryKey(primaryKey:AnyObject!)->Self!我仍然看到“找不到初始值设定项”