0

I have an app with CoreData written in obj-c and created a new VC in Swift. I want to create a new "Location" in my swift VC and "Location" is a managedObject in obj-c. I have Location.h in my bridging header.

let newLocation = Location()

error:

CoreData: error: Failed to call designated initializer on NSManagedObject class 'Location' 
-[Location setLocation:]: unrecognized selector sent to instance 0x7fa5928a4880
3
  • 4
    Have a look at the documentation: "If you instantiate a managed object directly, you must call the designated initializer (initWithEntity:insertIntoManagedObjectContext:)." Commented Feb 4, 2016 at 19:00
  • Yes, I was looking at that and was still confused. After looking into it a little more I got it to work. Thank you. Commented Feb 4, 2016 at 19:39
  • let newLocation = Location.init(entity: NSEntityDescription.entityForName("Location", inManagedObjectContext: Stack.sharedInstance().managedObjectContext)!, insertIntoManagedObjectContext: Stack.sharedInstance().managedObjectContext) Commented Feb 4, 2016 at 19:40

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.