title: Calling NSString extension defined in Swift from Objective C
body: <p>I have a a <code>String</code> extension which i want to use on <code>NSString</code> from <code>objective c</code>. As <code>String</code> in swift is a <code>struct</code> so its not exposed to <code>objective c</code>. So in order to call it from <code>objective c</code> i defined an <code>extension</code> on <code>NSString</code> in the same file. </p>
  
  <pre><code>public extension NSString {
  
          func htmlAttributedStringWithFont(font: UIFont, size fontSize: CGFloat = 17.0) -&gt; NSAttributedString? {
              let str = self as String
              return str.htmlAttributedStringWithFont(font: font)
          }
  
      }
  
  
  
     extension String {
  
          /// Converts an HTML String to NSAttributedString
          ///
          /// - Returns: NSAttributedString?
          func htmlAttributedString() -&gt; NSAttributedString? {
              guard let data = self.data(using: .utf16, allowLossyConversion: false) else {
                  return nil
              }
              guard let html = try? NSMutableAttributedString(
                  data: data,
                  options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
                  documentAttributes: nil) else { return nil }
              return html
          }
  
          /// returns and NSAttributedString optional from HTML content after applying specific font and size
          ///
          /// - Parameters:
          ///   - font: Font to be applied on the returned string
          ///   - fontSize: Size to be applied on the returned string
          /// - Returns: NSAttributedString?
          func htmlAttributedStringWithFont(font: UIFont, size fontSize: CGFloat = 17.0) -&gt; NSAttributedString? {
              let string = self.appending(String(format: "&lt;style&gt;body{font-family: '%@'; font-size:%fpx;}&lt;/style&gt;", font.fontName, fontSize))
              return string.htmlAttributedString()
          }
  }
  </code></pre>
  
  <p>The above two extensions are in the same file <code>String+Extension.swift</code>. I then tried to call the <code>htmlAttributedStringWithFont</code> method from my <code>objective c</code> class with <code>NSString</code></p>
  
  <pre><code>[str htmlAttributedStringWithFont:[UIFont systemFontSize]];
  </code></pre>
  
  <p>it gives me the following error</p>
  
  <pre><code> No visible @interface for 'NSString' declares the selector 'htmlAttributedStringWithFont:'
  </code></pre>
  
  <p>Any idea how i can use <code>String</code> extension in <code>Swift</code> from <code>Objective c NSString</code></p>