re: NSManagedObjectContext - Key Value compliant
re: NSManagedObjectContext - Key Value compliant
- Subject: re: NSManagedObjectContext - Key Value compliant
- From: Ben Trumbull <email@hidden>
- Date: Sun, 28 Oct 2007 16:25:54 -0700
Using Xcode 2.4 Tiger 10.4.10 I had a subclass of an
NSManagedObjectContext and used setValue and valueForKey on the extra
ivars I had defined. Worked fine on Tiger PPC and Intel. The compiled
app failed to launch in Leopard.
You can file a bug report with bugreport.apple.com
I have imported the project into XCode 3.0, Intel Leopard 10.0. I
have so far found that most (probably every) setValue:ForKey and
valueForKey on any of the iVars for the subclassed Moc fails. No
message, no warning, not even when using the debugger, silence - and
not going nowhere fast.
See the Key Value Coding documentation in the Foundation reference for
the KVC protocol. See the documentation for
+accessInstanceVariablesDirectly
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueCoding_Protocol/index.html#//apple_ref/doc/uid/TP40003780
>
Is this a bug or has there been a design change that I have missed.
It's a bug that a Tiger app does not run on Leopard.
It's a design change that compiled against the 10.5 SDK this won't
work. Mean people were doing bad things with ivars that did not
belong to them through KVC, and had to be punished (kinda joking).
The problem was that through KVC people were getting at private state
either without realizing it, or without fully appreciating how bad it
was. Come the end of the day, we all have to ship software, and we
all write some pretty nasty hacks from time to time. The point here
is to force people to actually write the hacks, **which they know
might not run on a future OS**, instead of allowing accidental binding
to private state.
I can get-around it by adding glue code for each get and each set in
the Moc subclass
That would be best.
Can someone tell me which other Object Classes will exhibit this odd
behaviour in Leopard.
Any class can ask KVC to do this. For Core Data classes,
NSManagedObjectContext and NSManagedObjectID do (subclassing
discouraged), but NSManagedObject does not (subclassing encouraged)
- Ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden