title: Allocating/initializing Swift object from Objective-C
body: <p>I am working on an app where I am getting an API response and need to create objects from this and put it in an Array to use later. The API call is made in Objective-C, but my new Object is made in Swift (it's an old app with mostly Objective-C code).</p>
  
  <p>The API call itself is working fine, but when I try to convert this the object an object is not made.</p>
  
  <p>This is the object code (Swift):</p>
  
  <pre><code>import Foundation
  
  @objc
  class GCBOKSProductInfo: NSObject, NSCoding {
  
  var featureName: String = ""
  var available: Bool = false
  
  static let sharedInstance = GCBOKSProductInfo()
  
  override init() {
      super.init()
  }
  
  init(featureName: String, available: Bool) {
      super.init()
  
      self.featureName = featureName
      self.available = available
  }
  
  convenience required init?(coder decoder: NSCoder) {
      guard let featureName = decoder.decodeObject(forKey: "featureName") as? String
          else { return nil }
  
      self.init(
          featureName: featureName,
          available: decoder.decodeBool(forKey: "available")
      )
  }
  
  func encode(with aCoder: NSCoder) {
      aCoder.encode(featureName, forKey: "featureName")
      aCoder.encode(available, forKey: "available")
  }
  
  }
  </code></pre>
  
  <p>and here is where I am trying to make an object out of the API response:</p>
  
  <p>NSMutableArray *result = [NSMutableArray arrayWithCapacity:[responseObject count]];</p>
  
  <pre><code>for (NSDictionary *boksProductInfoDict in responseObject) {
  
      NSString *featureName = boksProductInfoDict[@"FeatureNaam"];
      NSString *available = boksProductInfoDict[@"Beschikbaar"];
  
      GCBOKSProductInfo *boksProductInfo = [[GCBOKSProductInfo alloc] initWithFeatureName:featureName available:available.boolValue];
  
      [result addObject:boksProductInfo];
  }
  </code></pre>
  
  <p>The extracting of the featureName and available works (if I put a breakpoint in the object I see that it is made correctly), but the "boksProductInfo" never seems to be allocated/initialized correctly, so when I add it to the "result" array there is no information in the entry.</p>
  
  <p>If I try to po the "boksProductInfo" I get this:</p>
  
  <p>ProjectName.GCBOKSProductInfo: 0x60800005ee70</p>
  
  <p>And if I try to po "boksProductInfo.featureName" I get this:</p>
  
  <p>error: member reference type 'GCBOKSProductInfo *' is a pointer; did you mean to use '->'?</p>
  
  <p>error: incomplete definition of type 'GCBOKSProductInfo'
  forward declaration of 'GCBOKSProductInfo'</p>
  
  <p>Any idea where I might have it wrong?</p>