0

I'm working with third-party project, which I need to modify. Currently I've met the following strange code:

A function is declared as follows in Obj-C:

@interface CVASPlayer : NSObject

+ (void)optimizeForTheory:(CVGame *)game;

@end

@implementation CVASPlayer

+ (void)optimizeForTheory:(CVGame *)game {
    ASGamerParser::optimizeForTheory((Game *)[game getCPPClass]);
}

@end

And it is called from Swift as:

CVASPlayer.optimize(forTheory: game)

The method names doesn't match - optimize and optimizeForTheory. How it works? And forTheory is strangely moved to a parameter name, how is it possible?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Artem Mostyaev
  • 3,874
  • 10
  • 53
  • 60
  • 1
    The naming convention is different in Obj-C and Swift and hence the generated Swift headers for Obj-C functions will have different naming than in Obj-C. You can check the generated Swift header file in Xcode by opening the header file for the Obj-C implementation file, then clicking on the `Related Items` button and selecting `Counterparts` --> Swift header. – Dávid Pásztor Apr 09 '19 at 09:41
  • Possible duplicate of [Converting to Swift 3 renamed my own Objective-C method](https://stackoverflow.com/questions/40157131/converting-to-swift-3-renamed-my-own-objective-c-method) – Martin R Apr 09 '19 at 09:45

0 Answers0