Preetam Jadakar
Preetam Jadakar

Reputation: 4561

Accessing parameterised swift method in ObjC class

Swift Class:

@objc public class XyzClass: NSObject {

    var newlyVar = String()
    func abcd (abc:String?, name:Int) {

    }
    func mymethod(userId:Int32?,startIndex:Int32?, lastIndex:Int32?, m_bankId:Int32?, m_DownPayment:Int32?,m_maxTenure:Int32?, m_salary:Int32?) {

    } 

    func sampleMethod (userId:Int32,startIndex:Int32, lastIndex:Int32, m_bankId:Int32, m_DownPayment:Int32, m_maxTenure:Int32, m_salary:Int32, m_selfemployed:Int32, m_UAENational:Int32, complitionHandler: ( _ success:Bool, _ loans:[Loan]) -> Void){
            complitionHandler(true,[])
    }
}

In ObjC class, I'm accessing as:

LoanParser *lp = [[LoanParser alloc]init];
[lp abcdWithAbc:@"" name:32];

Method abcd and variable newlyVar is accessible but the mymethod and sampleMethod isn't.

Anything I'm missing here?

Concern I feel is: Loan class conforms to Mappable protocol

Upvotes: 2

Views: 63

Answers (1)

Oskar
Oskar

Reputation: 3702

Int32? cannot be represented in Objective-C. Try changing it to Int32.

The String can be represented as optional because it converts to an NSString object which can be nil, so the bridging has a way to represent no value.

Upvotes: 2

Related Questions