0

Recently I have been experimenting with Coredata by making a couple of applications locally. I noticed whenever I make an object and save things onto core data, I do not seem to be able to view the complete parameters provided by the framework when attempting to create an object. I don't know what the terminalogy is for this step, but I was attempting this:

 let managedObjectContext = (UIApplication.sharedApplication().delegate as AppDelegate).managedObjectContext
        let entityDescription = NSEntityDescription.entityForName("Feeditem", inManagedObjectContext: managedObjectContext!)

let feedItem = FeedItem( <--- PROBLEM RIGHT HERE

Instead of getting this to pop up:

(entity: entityDescription!, insertIntoManagedObjectContext: managedObjectContext!)

I get this: enter image description here

Why is this so?

Here is a project in which the same thing was happening: https://github.com/Somnibyte/Errands

Guled
  • 659
  • 1
  • 5
  • 18
  • There is no FeedItem in the project you uploaded. You should make your question match your example. – matt Oct 31 '14 at 01:31
  • Matt, I was trying to do another experiment. The point is that both of them were behaving like this. It's really annoying. – Guled Oct 31 '14 at 16:26

1 Answers1

1

Works perfectly for me on the project you uploaded:

enter image description here

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Do you recommend that I delete Xcode and then re-download it? This is so bizarre. I knew I was doing everything right! – Guled Oct 31 '14 at 16:25
  • I am using Xcode 6 on Yosemite by the way. If we both have the same configurations, than this is quite an odd bug. – Guled Oct 31 '14 at 16:48
  • Hmm. I'm still on Mavericks. Could that really be the difference? ... Have you restarted the computer? I find that this is sometimes necessary in order to slap Xcode across the head. Also, consider doing a cleaning as I describe here: http://stackoverflow.com/a/6247073/341994 – matt Oct 31 '14 at 17:07
  • Yeah, I did quite a lot of cleaning various time, but with no luck. I found another person with the same problem. Over here: . I tried a solution found on the thread where you could modify the entity class. My entities class is currently "ErrandModel", I changed it to "Errands.ErrandModel". I added the projects name before the period. And it seem to print out the core data test, BUT with an error on top: – Guled Oct 31 '14 at 17:27
  • 2014-10-31 12:28:27.530 Errands[2716:39234] CoreData: warning: Unable to load class named 'Errands.ErrandModel' for entity 'ErrandModel'. Class not found, using default NSManagedObject instead. (entity: ErrandModel; id: 0xd000000000080000 ; data: { info = Test; item = Test; quantity = Test; }) – Guled Oct 31 '14 at 17:28
  • Here is the thread by the way: http://stackoverflow.com/questions/26599574/cant-instantiate-subclass-of-nsmanagedobject?rq=1 – Guled Oct 31 '14 at 17:29
  • Okay. I've seen a lot of stuff that looks related. I think what we're seeing here is a Swift bug having to do with inherited initializers. – matt Oct 31 '14 at 18:47
  • Thank you for the help matt, I got it to work. Just fetched the data, it seems that it was there, but I couldn't print the data being saved. Nonetheless, it works fine now. – Guled Dec 05 '14 at 01:01