• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: set values in coredata
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: set values in coredata


  • Subject: Re: set values in coredata
  • From: Brian Todd <email@hidden>
  • Date: Sat, 10 Feb 2007 21:33:33 -0800

Thank you for your patience. I read all of these documents prior to asking my question and I wasn't clear which pieces were necessary to simply modify a value in an instance of a managed object. I tried to write this code and while it compiles and runs it doesn't change the data. I stepped through this method and it is getting called so I must be missing something obvious.
I left out the predicate and the sort descriptor because I think they are optional. The black code I left out because I am trying to use key-value coding to change the value and I don't know how it fits into the picture.


	NSManagedObjectContext *context = [self managedObjectContext];
	NSEntityDescription *dailyValuesEntity = [NSEntityDescription
				entityForName:@"DailyValue"
				inManagedObjectContext:context];
	NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
	[request setEntity:dailyValuesEntity];
	[request setValue:[NSNumber numberWithInt:100] forKey:@"value"];

// left out because I am trying to use key-value coding to change the value.
NSError *error = nil;
NSArray *array = [managedObjectContext executeFetchRequest:request error:&error];



p.s. I will try to be more precise with my terminology. After reading a lot of documentation all the terms start to mix in my head.


On Feb 10, 2007, at 8:00 PM, mmalc crawford wrote:


On Feb 10, 2007, at 7:44 PM, Brian Todd wrote:

When I change a value in a text field I would like all the values in a core data entity to change based on the modified value. I have been trying to figure out if there is a way to do this with bindings but I haven't figured it out yet.

The Core Data documentation strongly recommends *not* trying to learn bindings and Core Data at the same time:
<http://developer.apple.com/documentation/Cocoa/Conceptual/ CoreData/Articles/cdBeforeYouStart.html>



The reason that I have the calculated values in their own entity instead of created when I need them is that the user can choose to modify them individually and disable the calculation.

It is not clear what this means.
It would be helpful if you used appropriate terminology -- for example, you should differentiate between entities and managed objects.



If as I suspect, there is no elegant way to use bindings for this. What is the most straightforward way to modify entity values in coredata?

Assuming you mean, how do you change property values in an instance of a managed object, this is covered here:

<http://developer.apple.com/documentation/Cocoa/Conceptual/ CoreData/Articles/cdUsingMOs.html#//apple_ref/doc/uid/ TP40001803-212651>


It seems like it should be just a couple lines of code but I can't tell from Apple's docs if I need to create a fetch request and subclass NSManagedObjectContext just to edit a value.

Nowhere does the documentation suggest subsclassing NSManagedObjectContext.
You use a fetch request to retrieve managed objects, as described here:
<http://developer.apple.com/documentation/Cocoa/Conceptual/ CoreData/Articles/cdFetching.html>


mmalc


Brian Todd email@hidden www.dancelesson.us


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: set values in coredata
      • From: mmalc crawford <email@hidden>
References: 
 >set values in coredata (From: Brian Todd <email@hidden>)
 >Re: set values in coredata (From: mmalc crawford <email@hidden>)

  • Prev by Date: Re: pasteboard issues
  • Next by Date: Re: set values in coredata
  • Previous by thread: Re: set values in coredata
  • Next by thread: Re: set values in coredata
  • Index(es):
    • Date
    • Thread