PruitIgoe
PruitIgoe

Reputation: 6384

iOS: Passing Array of Core Data entities from Obj-C to Swift

I have an Objective-C viewcontroller and within it I am trying to pass an array of core data entities (GroupToCustRelation) to a property of a Swift file.

In my Swift file I tried to do this:

var arrCustomers:[GroupToCustRelation] = []

I get a use of undeclared type error. Just starting on Swift so any help would be appreciated. How do I declare an empty array that is expecting Core Data entities?

Upvotes: 0

Views: 65

Answers (1)

anon
anon

Reputation:

Your core data model classes are probably Objective-C then. To make them available to your Swift code you need to import those headers in your Swift Bridging Header. It should be called [TargetName]-Bridging-Header.h. If you didn’t let Xcode create this file when you first added Swift code to your project you can manually create such a header and enter it’s name in your targets build setting Objective-C Bridging Header which you will find in the Swift Compiler - General section.

Upvotes: 1

Related Questions