-2

I want to convert this Swift code to Objective C. I searched and did not find a way to convert automatically . Is there any way that can help convert ?

let token="0000000009"
    SkyIdConfig.shared.setup(With: token)
var skyIdView:SkyDocumentsAnalyzer?
        SkyIdConfig.shared.loadAndConfigure(){[unowned self] isConfigured,error in
                    if error != nil || !isConfigured {
                        print(error?.localizedDescription ?? "Error !!!!")
                        return
                    }
                    DispatchQueue.main.async {[unowned self] in
                        self.skyIdView=SkyIdBuilder.shared.getDocumentAnalyzerInstance(with: "03", lang: "fra")
                        if self.skyIdView != nil
                                {
                                    self.skyIdView!.delegate=self
                                    self.skyIdView?.modalPresentationStyle = .fullScreen
                                    self.present(self.skyIdView!, animated: true, completion: nil)
                                }else{
                                          print("Error in config loading")
                                     }
                    }

        }
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • There's an obvious answer you won't like: just learn Objective-C. – Alexander Jun 29 '20 at 15:11
  • 2
    Why would you ever convert Swift code to Obj-C? Simply make it accessible from Obj-C. Swift and Obj-C have a very high level of interoperability, so there's almost no justification for converting Swift code to Obj-C. – Dávid Pásztor Jun 29 '20 at 15:12
  • Why do you want to convert from swift to objective-c if I may ask? I can't think of anything why it would be needed. Might help with coming up with an answer – Tomo Norbert Jun 29 '20 at 15:12
  • the user did not ask if he should convert or not, to me its total legitim to try understand the languages by converting. Some frameworks and even whole apps are still written in objective-c on purpose. Don't become nervious, you will understand swift when trying to convert it back to obj-c assuming you know obj-c. – Ol Sen Jun 29 '20 at 15:17
  • But you may edit your question to have at least correct swift before converting. – Ol Sen Jun 29 '20 at 15:21

1 Answers1

0

Of course there is a way to convert ..

..manually. Which is the best way to understand whats going on.

your token is probably an

NSString *token = @"0000000009";

depending on the Class definition you have to look up how SkyIdConfig is done..

//assuming its something like..
[[SkyIdConfig shared] setupWith:token]; 

SkyDocumentsAnalyzer *skyIdView = [[SkyDocumentsAnalyzer alloc] init];

[[SkyIdConfig shared] loadAndConfigure];

before going forward in code read more about dispatching in objective-c (aka c) here...

Ol Sen
  • 3,163
  • 2
  • 21
  • 30