2

I'm using Core Data and i have a managed object that the description states its data is fault.
I try to access a property with dot syntax but it's nil.
If I use -[object valueForKey:@"key"]; the object fires fault and I get the correct value. from then on i can access using object.key and it works.

Why does the object data stays fault even after accessing the property?

EDIT: First I want to add that the property in question is of type NSDictionary and defined as Transformable in the model.

The code is simply:
NSDictionary *d = object.property; where object is a NSManagedObject that is managed by CoreData. After this line d is nil.

NSDictionary *d = [object valueForKey:@"property"]; After this line d is the correct value.

Or Arbel
  • 2,965
  • 2
  • 30
  • 40
  • Can you give a code example? It's difficult to help you without one – arnoapp Sep 06 '12 at 11:29
  • 1
    I have created a simple Core Data project with a transformable NSDictionary attribute, and accessing the value with the property/dot syntax worked without problem. Did you include the generated .h file for the entity? – Martin R Sep 06 '12 at 14:52
  • i created a subclass with .m and .h files. i did not know Core Data generates the .h files. – Or Arbel Sep 06 '12 at 15:02
  • Select the Entity and choose "Editor -> Create NSManagedObject Subclass ..." from the menu. – Martin R Sep 06 '12 at 15:08

1 Answers1

4

Had seen a similar issue a while ago. The model class had @synthesize for the properties instead of @dynamic.

Gopal R
  • 732
  • 5
  • 8
  • I can't believe this ... I've been messing with some issue for 2 days now and this was the problem. So stupid :) Thanks man! – Shai Mishali Oct 13 '13 at 16:49