Siddharth
Siddharth

Reputation: 9574

Swift 3, throwing NSInvalidArgumentException

I have real simple code, but it throws a NSInvalidArgumentException, I wonder why?

My class is defined like this with a construtor

class mNoxGetDriverDetails : HTTPRestClient {

    private var demographicsPojo : DemographicsPojo

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

I call the following in a Test and I get a NSInvalidArgumentException at here

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

What could I be doing wrong here?

Edit : More code

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())
    }

Upvotes: 1

Views: 338

Answers (1)

dengST30
dengST30

Reputation: 4037

Here is my case,

to solve it by

Add -all_load to the other linker flags in your build settings.

-all_load forces the linker to load all object files from every archive it sees, even those without Objective-C code.

Upvotes: 1

Related Questions