Posting an answer if it helps someone in solving the same problem.
I found that a fairly direct solution to how to do this is given in the iOS Developer Library. Please refer to the following link:
https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_75
Apple Doc says:
To import a set of Objective-C files into the same target application as your Swift, you rely on the Objective-C bridge header to make the files in Swift. Xcode suggests creating this header file when you add a Quick file to an existing Objective-C application or an Objective-C file for an existing Swift application.
So, I created the file MyApp-Bridging-Header.h and just added the following line:
#import "MyModel.h"
Now it allows me to use the model in my ViewController.swift as follows:
var myModel = MyModel() myModel.name = "My name" myModel.dobString = "11 March,2013" println ("my model values: Name: \myModel.name and dob: \myModel.dobString")
FYI to anyone trying to figure it out. If you need to create a bridge file from scratch, you must also specify the path to it in the build settings> Swift Compiler> Objective-C Bridging Header.
shah1988 Jun 04 '14 at 10:03 2014-06-04 10:03
source share