Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import classes with Swift iOS

Tags:

swift

I'm trying Swift and I'm having some troubles.. I have a TableViewController.swift and also a DataModel.swift but I don't know how to import DataModel class into TableViewController to use in it. I'm trying with

import DPBDataModel.swift  

but it doesn't works (No such module)

Thanks for your replies!

like image 769
dpbataller Avatar asked Jun 04 '14 12:06

dpbataller


People also ask

Can I mix Objective-C and Swift?

You can use Objective-C and Swift files together in a single project, no matter which language the project used originally. This makes creating mixed-language app and framework targets as straightforward as creating an app or framework target written in a single language.

How do imports work in Swift?

An import declaration allows your code to access symbols that are declared in other files. However, if more than one module declares a function or type with the same name, the compiler may not be able to tell which one you want to call in code.

How do I import a Swift class into Objective-C?

Import Swift code into Objective-C within the same framework: Under Build Settings, in Packaging, make sure the Defines Module setting for that framework target is set to Yes. Import the Swift code from that framework target into any Objective-C .

How do I import a bridging header in Swift?

To create an Objective-C bridging header file, all you need to do is drag some Objective-C code into your Swift project – Xcode should prompt you with the message "Would you like to configure an Objective-C bridging header?" Click "Creating Bridging Header" and you'll see a file called YourProjectName-Bridging-Header.


1 Answers

Try just using your DataModel class into TableViewController without importing anything ;-)

like image 125
Zedenem Avatar answered Sep 26 '22 20:09

Zedenem