Cannot convert value of type 'String' to expected argument type
<p>I've created separate swift class in my project to collect all required information and validation as follow:</p>

<p><strong>Config.swift</strong></p>

<pre><code>public class Config: NSObject {    
    func isValidEmail(testStr:String) -&gt; Bool {
        let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"
        let range = testStr.rangeOfString(emailRegEx, options:.RegularExpressionSearch)
        let result = range != nil ? true : false
        return result
    }
}
</code></pre>

<p>But problem is when I call that function in anther class, I've faced following error:</p>

<pre><code>if (Config.isValidEmail(txtEmail.text!))
</code></pre>

<blockquote>
  <p>Cannot convert value of type 'String' to expected argument type
  'Config'</p>
</blockquote>

<p>If I did like that as follow, got different error.</p>

<pre><code>Config.isValidEmail(txtEmail.text)
</code></pre>

<blockquote>
  <p>Cannot convert value of type 'String?' to expected argument type
  'Config'</p>
</blockquote>

<p>I don't know why. Please help me how to solve.</p>