0

I am trying to swizzle NSAttributedString but getting a compile error:

extension NSAttribtuedString {

   @objc convenience init(swizzledString: String, attributes: [NSAttributedString.Key : Any?] {
       .....
   }
}

Error

Method cannot be marked @objc because type of parameter 2 cannot be represented in Objective C

The error makes sense. Any way we can solve this to keep the function signature and swizzle the init function?

Tal Zion
  • 6,308
  • 3
  • 50
  • 73

1 Answers1

1

You get the error, because swift's dictionary type does not exist in objective-c. You would have to use NSDictionary:

@objc convenience init(swizzledString:String, attributes:NSDictionary)
Jiri Volejnik
  • 1,034
  • 6
  • 9