small medium large xlarge

Back to: All Forums  Core Data
13 Mar 2010, 19:19
Tom Hudgins (2 posts)


I’ve built a relatively simple Core Data app along the lines of the recipe app. I have an Event entity that has a date attribute and I can add and delete Events to the tableview no problem. I wanted to default the date on new entries to today so I subclassed the Entity NSManagedObject and added an awakeFromInsert method to set the date. That works fine too.

I then wanted to default another property of the Event - the name of a group (of people) - to a value that I’m holding in another Entity/object.

So, in awakeFromInsert, I made an NSFetchRequest, executed it, and got the name value of the first object in the returned results. All seemed fine until I noticed that now, when I click the Add button on the Event table, I get two entries in the table each time.

A little further investigation revealed that there really is only one object, it’s just showing up twice. If I save and restart the program, only one Event shows up. If I add another Event, two entries are shown (for a total of three). If I save and restart though, I only see two. I’ve verified in the XML store that there is only the one event object added for each Add click.

Clearly the TableView is messed up but it seems to be due to the FetchRequest call. If I comment that out, it works fine.

I’m totally stumped on this. Hope someone can shed some light.


15 Mar 2010, 06:39
Marcus S. Zarra (284 posts)

Questions like these are more ideally suited for StackOverflow as you will get far more eyes on the question. I would highly recommend reposting it over there.

In addition, without understanding how you have wired up your UI, it is difficult to offer suggestions based on the description you have given so far.

You must be logged in to comment