我在一个混合项目中使用 Realm-Cocoa。虽然遇到了一些棘手的问题,但现在我真的卡住了。我尝试了几种方法,但都没有帮助。
这个类编译时没有任何问题,但在运行时崩溃:
致命错误:使用未实现的初始化程序“init()”为类“MyApp.Model”
这是这个类:
import Foundation
import Realm
import SwiftyJSON
class Model: RLMObject {
dynamic var contactId: String
dynamic var userId: String
dynamic var contactType: String
dynamic var firstName: String
dynamic var lastName: String
dynamic var middleName: String
dynamic var jobTitle:String
dynamic var department: String
dynamic var location: String
dynamic var serviceName: String
dynamic var serviceType : String
dynamic var emails : String
dynamic var addresses :String
dynamic var profilePictureSHA1 : String
dynamic var extNum : String
dynamic var fqExtNum : String
dynamic var ipbxId : String
dynamic var phone : String
dynamic var fax : String
dynamic var dispWhenNoext : Bool
dynamic var dispInContDir : Bool
override class func primaryKey() -> String? {
return "contactId"
}
init(
contactId: String,
userId: String,
contactType: String,
firstName: String,
lastName: String,
middleName: String,
jobTitle: String,
department: String,
location: String,
serviceName: String,
serviceType: String,
emails: String,
addresses: String,
profilePictureSHA1: String,
dispWhenNoext: Bool,
dispInContDir: Bool,
extNum: String,
fqExtNum: String,
ipbxId: String,
phone: String,
fax: String)
{
self.contactId = contactId
self.userId = userId
self.contactType = contactType
self.firstName = firstName
self.lastName = lastName
self.middleName = middleName
self.jobTitle = jobTitle
self.department = department
self.location = location
self.serviceName = serviceName
self.serviceType = serviceType
self.emails = emails
self.addresses = addresses
self.profilePictureSHA1 = profilePictureSHA1
self.dispInContDir = dispInContDir
self.dispWhenNoext = dispWhenNoext
self.extNum = extNum
self.fqExtNum = fqExtNum
self.ipbxId = ipbxId
self.phone = phone
self.fax = fax
super.init()
}
override static func ignoredProperties() -> [String] {
return ["contactFlag", "dttmCreated", "nickName", "customField1", "customField2", "customField3", "serviceId", "parentServiceId", "branchId", "hideInAA", "vooEnableFlag", "devLockDown", "tenantId", "serviceEmailId", "siteCustomerId", "branchCode", "accessCode"]
}
}