title: How to call a factory method of an Objective-C class from Swift?
body: <p>I have an obj-c class that uses a factory method to instantiate itself as a singleton. I added that class to my Swift bridge header and want to call this factory method from a swift class. However, XCode won't let me.</p>
  <p>The obj-c code is:</p>
  <pre><code>@interface MOAssistant : NSObject {
  ...
  + (MOAssistant *)assistant;
  
  @end
  </code></pre>
  <p>The Swift code is:</p>
  <pre><code>let assistant = MOAssistant.assistant;
  </code></pre>
  <p>With this code I get the error:</p>
  <blockquote>
  <p>'assistant()' is unavailable: use object construction 'MOAssistant()'</p>
  </blockquote>
  <p>I read about <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html#//apple_ref/doc/uid/TP40014216-CH4-XID_26" rel="noreferrer">mapping factory methods to Swift initializers</a> but I wonder why I simply can use:</p>
  <pre><code>let fm = NSFileManager.defaultManager;
  </code></pre>
  <p>even though defaultManager is also a factory method. This is confusing. I read other postings here on SO like these:</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/24214061/how-are-objective-c-factory-methods-converted-into-swift-convenience-initializer">How are Objective-C factory methods converted into Swift convenience
  initializers?</a></li>
  <li><a href="https://stackoverflow.com/questions/24093693/create-swift-instance-from-objective-c-factory-method">Create Swift instance from Objective-C factory
  method</a></li>
  </ul>
  <p>but none of them explain why Swift behaves differently. Using the recommended way (<code>MOAssistant()</code>) is no solution as it directly calls the initializer of that class (what I don't want).</p>