title: Swift access to C Struct
body: <p>I am developing a OS X Swift app for parsing cvs files. It runs successfully in Objective-C. Then I changed to Swift and for performance improvements I developed the parse/import engine in C. It is 5 times faster as in Swift or Objective-C - nice. But I have trouble to exchange the data between C and Swift - especially with Struct:</p>
  
  <p><strong>BridgingHeader:</strong></p>
  
  <pre><code>#include "ToolBoxC.h"
  </code></pre>
  
  <p><strong>ToolBoxC.h:</strong></p>
  
  <pre><code>void loadFile(const char *fileName, const char *delimiters, const char *xRegex, int xRegexColumn, int xColumn, int yColumn, int xRow, int yRowShift, bool collectStrings);
  
  typedef struct {
  
                      char **headerArray;
                      int numberHeaderRows;
                      char **dateArray;
                      int numberDateRows;
                      int **valueArray;
                      char ***stringArray;
                      int numberValueRows;
                      int numberValueColums;
          } FileStruct;
  
  typedef struct {
  
                      FileStruct fileContent[10000];
  } FilesStruct;
  
  struct FilesStruct filesContent;
  </code></pre>
  
  <p><strong>ToolBoxC.c:</strong></p>
  
  <pre><code>struct FileStruct {
  
      char **headerArray;
      int numberHeaderRows;
      char **dateArray;
      int numberDateRows;
      int **valueArray;
      char ***stringArray;
      int numberValueRows;
      int numberValueColums;
  };
  
  struct FilesStruct {
  
      struct FileStruct fileContent[10000];
  };
  
  void loadFile(const char *fileName, const char *delimiters, const char *xRegex, int xRegexColumn, int xColumn, int yColumn, int xRow, int yRowShift, bool collectStrings) {
  
  // some stuff
  
      struct FileStruct fileContent;
  
      fileContent.headerArray = headerArray;
      fileContent.numberHeaderRows = numberHeaderRows;
      fileContent.dateArray = dateArray;
      fileContent.numberDateRows = numberDateRows;
      fileContent.valueArray = valueArray;
      fileContent.stringArray = stringArray;
      fileContent.numberValueRows = numberValueRows;
      fileContent.numberValueColums = numberValueColumns;
  
      filesContent.fileContent[numberFiles] = fileContent;
  
  return;
  }
  </code></pre>
  
  <p>All the parsed data are stored in <code>struct FilesStruct filesContent</code>. The parsing is started by calling the function loadFile() with parameters from Swift. That works fine. Also the parsing is OK. But how can I access to the data in <code>struct FilesStruct filesContent</code> from Swift?</p>
  
  <p>Thanks, Matthias.</p>