1
votes

I have a Swift class that inherits from a NSObject-derived class written in Objective-C.

@objc class DisplayMessage : JSQMessage, BaseModel
{
 init(var userId:String, var userName:String, var message:String, var group:Group)
    {
//...
     }
}

How can i call this init from Objective-C?

I only see the JSQMessage (the NSObject-derived class written in obj-c) inits.. + a default init method with no parameters

UPDATE

i inserted an @objc in front of the init in swift and i get the error

Method cannot be marked @objc because the type of the parameter 1,2,3,4 cannot be represented in objective-c

After i saw this, i changed the String type to NSString and the Group class is already @objc; I still receive the same error

UPDATE 2

i've tried the same thing with Int initializer and i get the same error

  @objc init(var numberLol:Int)
{
    super.init(senderId: "", senderDisplayName: "", date:nil,  text: nil)
}
1
have you tried replacing String by NSString? - tkanzakic
yes, i've mentioned this in UPDATE 1 - Alex
oops!, sorry, I miss that - tkanzakic

1 Answers

0
votes

OK so the answer was that i have to remove the "var" from each parameter in the init. Why? idk