0

I have library developed in Objective C. In that library, one of my property expects the registration of my class. So that it will call the pre-defined method on that class. (Some what like delegate).

Below is my objective C property and how I set in swift class:

Builder.registerMapperClass(KeyMapper().self)

For now, I have passed KeyMapper().self, but this is not working. I also tried KeyMapper(). Because in Objective C, it is throwing error as below

-[PROJECTNAME.KeyMapper mapPropertyForKey:ForClass:]: unrecognized selector sent to instance 0x7f9911f22c60"

Here, PROJECTNAME is appended before the class name. Now, since this method will be called on Class which is not present with name PROJECTNAME.KeyMapper but KeyMapper.

So how to solve this issue?

DShah
  • 9,768
  • 11
  • 71
  • 127
  • Did you try doing just Builder.registerMapperClass(KeyMapper)? using KeyMapper() will pass in an instance of the class, not the class itself – Knight0fDragon Oct 14 '15 at 16:20
  • @Knight0fDragon: I tried that but it is giving a compile time error saying that KeyMapper.type should be given and we cant give direct class. – DShah Oct 14 '15 at 16:29
  • How about let class = KeyMapper(); Builder.registerMapperClass(class.dynamicType)? – Knight0fDragon Oct 14 '15 at 16:38
  • I tried with but with swift 2.0, it is giving me error as: PATH_TO_FILE/BaseService.swift:67:58: Cannot convert value of type 'KeyMapper.Type' to expected argument type 'KeyMapperAdapter!' – DShah Oct 15 '15 at 05:31
  • What parameter type does registerMapperClass take? – Knight0fDragon Oct 15 '15 at 20:04

0 Answers0