Swift 3,抛出NSInvalidArgumentException

时间:2017-02-13 05:31:22

标签: swift syntax swift3

我有真正的简单代码,但它会抛出一个NSInvalidArgumentException,我想知道为什么?

我的班级是这样定义的,有一个建设者

class mNoxGetDriverDetails : HTTPRestClient {

    private var demographicsPojo : DemographicsPojo

    init(phoneNumber: String, passcode :String) {   
    // init code 
    // super.init()
    }

我在Test中呼叫以下内容,并在此处获得NSInvalidArgumentException

let getDriverDetails : mNoxGetDriverDetails = mNoxGetDriverDetails(phoneNumber: "94644187512", passcode : "passcode")

我在这里做错了什么?

修改:更多代码

class mNoxGetDriverDetails : HTTPRestClient {
private var demographicsPojo : DemographicsPojo

    init(phoneNumber: String, passcode :String) {

        let demographicsPojoData : NSDictionary = [
            "isDemographicsActive":DemographicsPojoWrapper.IsDemographicsActive.YES,
            "demographicsRoleType" : DemographicsPojoWrapper.DemographicsRoleType.DRIVER,
            "mobilePhone":phoneNumber,
            "isTermsAndConditonsAccepted" : DemographicsPojoWrapper.IsTermsAndConditonsAccepted.YES]
        demographicsPojo = DemographicsPojo(dictionary: demographicsPojoData)!
        let demographicsPojoWrapperData : NSDictionary = ["demographicsPojo":demographicsPojo,
                                                          "isMinimalObject" : true,
                                                          "minimalWrapperObjectPurpose": AllTablesGlobals.AllWrappersObjectPurpose
                                                            .GET_SPECIFIC_RECORD_FROM_BACKEND]
        let demographicsPojoWrapper : DemographicsPojoWrapper = DemographicsPojoWrapper(dictionary: demographicsPojoWrapperData)!
        super.init(apiUrl: "Driver/getDriverDetails", operation: God.mNoxAPIs.mNoxGetDriverDetails, postData: demographicsPojoWrapper.dictionaryRepresentation())
    }

1 个答案:

答案 0 :(得分:1)

这是我的情况,

解决

在构建设置中的其他链接器标志中添加-all_load

-all_load强制链接器从它看到的每个存档中加载所有目标文件,即使是没有Objective-C代码的文件。