Re: CoreData and ManagedObjects
Re: CoreData and ManagedObjects
- Subject: Re: CoreData and ManagedObjects
- From: mmalcolm crawford <email@hidden>
- Date: Thu, 23 Mar 2006 14:51:39 -0800
On Mar 23, 2006, at 12:10 PM, Bobby B wrote:
I'm building a CoreData application, and I'm having some trouble
accessing the properties of my entities. From what I've been reading,
it seems to access a CoreData entity and it's properties (as keys),
you do the following:
Could you please let me know what documentation you read that led you
to believe the approach you describe below is anything like correct?
I'm not sure how you would arrive at this conclusion from Apple's
documentation suite. (Lest my tone be misinterpreted here, I'm
asking seriously. I want to know so that if it's a problem with the
official docs it can be remedied.)
NSManagedObjectContext * context = [[NSApp delegate]
managedObjectContext];
NSManagedObject * girlEntity =
[NSEntityDescription entityForName: @"Girl" inManagedObjectContext:
context];
No. entityForName... returns an instance of NSEntityDescription.
You also need to properly differentiate between entity and instance.
[girlEntity didChangeValueForKey:@"image"];
Why are you invoking this method?
(I've also tried, in place of context, [self [managedObjectContext])
Why?
My Entity in xcdatamodel is "Girl", and it has a property called
"image" that is set to "Binary." I have the above code in a "load
picture" action. When the user clicks "load button", it does the
above code, plus setting the image outlet to the correct picture (via
the myData).
It's not at all clear what this means in terms of application
architecture.
It's also not clear if somehow you're creating (or at least trying to
create) a new managed object each time the "load button" action is
invoked. How are you actually managing your user interface?
If you're using Cocoa bindings, I strongly suggest that you stop
using Core Data for now and experiment with using bindings by
themselves so that you understand that technology before complicating
matters further. When you return to Core Data, look first at the
"Low level Core Data tutorial" <http://developer.apple.com/
documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/index.html> to
get an understanding of how Core Data works without the distraction
of a user interface. See also <http://developer.apple.com/
documentation/Cocoa/Conceptual/CoreData/Articles/cdBasics.html#//
apple_ref/doc/uid/TP40001650-DontLinkElementID_9>.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden