Sanif SS
Sanif SS

Reputation: 642

Swift init with closures is not visible in Objective C

My swift custom initilizer with closure is not visible in the objective c code.

 init(url:String,request:ABaseRequest,
  type:AnyClass, success:(ABaseResponse)->Void,
   failure:(ResponseCode,NSError)->Void) {

    ......
    ......
}

where as init without closure is visible

 init(url:String,request:ABaseRequest,type:AnyClass) {
    ......
    ......
}

Do you guys know how to solve this issue?

Upvotes: 0

Views: 426

Answers (2)

Sanif SS
Sanif SS

Reputation: 642

After inspecting whole code I found the problem in my code. A class used inside my closure is not annotated with @objc ! . So be careful guys, each and every classes that is going to be exposed to objective c should be annotated with @objc. Thanks.

Upvotes: 1

Anatoli P
Anatoli P

Reputation: 4891

By now you may have already solved the problem. I've run into a similar one myself.

Unless there are other problems, the visibility issue can be fixed by trying to build the project. If you introduce something new in your Swift code, it may not be immediately visible to Objective-C code, but building the project should fix it.

If there is another problem related to your custom initializer, the compiler will tell you when you try to build. If that is the case, share the problem here.

Upvotes: 0

Related Questions