2016-12-12 22 views
0
のための実装されていない初期化 'init()'の使用

私は混合プロジェクトで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"] 
    } 
} 
そのDOCOによると、あなたはそれ便利なメソッドではなく、指定された初期化子作るべき https://realm.io/docs/swift/latest/#adding-custom-initializers-to-object-subclasses

答えて

1

はでカスタムサブクラス初期化子とスウィフトイントロスペクションの問題についてレルムDOCOを参照してください。とにかく、試しに値する。次のようなもの:

convenience 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.init() // NB: 'self' not 'super' 

    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 
} 
関連する問題