1

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)
}
3
  • have you tried replacing String by NSString? Commented Jan 9, 2015 at 8:08
  • yes, i've mentioned this in UPDATE 1 Commented Jan 9, 2015 at 8:09
  • oops!, sorry, I miss that Commented Jan 9, 2015 at 9:40

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

Why were you using var in the first place?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.