views:

46

answers:

1

Hi,

I've a problem with KVO and I just can't find out what it is.

I have a screen that can be used to edit or create a record. That record is represented by a model object that holds a number of variables of type NSString.

The controller for that string has an instance variable to hold the model currently being worked on. When I open the window to create a new record, I create a new entity on my managed object context, assign the newly created entity to that instance variable and display the window - no problems.

I am using manual notifications in some fields of my model object because it inherits from NSManagedObject.

But when I try to edit a record - by fetching it from Core Data and doing the same thing - I get the error: [ addObserver:forKeyPath:options:context:] is not supported. Key path: username

NSLogging the object shows that its of the correct type. Any clues?

+1  A: 

That error make it feel like a set is involved somewhere. Are you sure you're setting the instance variable to the model object directly, instead of a set of them (possibly even a set with only one member)?

jmah
Thanks, that was it. I was casting from NSArray to my model object and just couldn't see it.
Rui Pacheco
Good to hear. Care to upvote and accept this answer then? ;)
jmah
Can't vote, not enough points.
Rui Pacheco
Voted now, don't want people to think I forget those who help me :)
Rui Pacheco