0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

ah, duh. I had just sent an email explaining how to expose Obj-C to Swiss to my co-workers...thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.