• 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: programmatically updating an MO's attribute/field {MOC is updated, but data is NOT stored}
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programmatically updating an MO's attribute/field {MOC is updated, but data is NOT stored}


  • Subject: Re: programmatically updating an MO's attribute/field {MOC is updated, but data is NOT stored}
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Mon, 30 Jan 2006 12:15:37 -0800

I've decided to populate the binary 'memoData' field to avoid a layout error.
The MOC appears okay before saving. But the Save (without error) doesn't actually
save the memoData.


Any Ideas?

Ric.

1) The Code:

EntityManagedObject *theObject = [[gvRegionMapController selectedObjects] objectAtIndex:0];
NSAttributedString *myString = [[NSAttributedString alloc] initWithString:@"Hello World!"];
NSData *myData = [NSData dataWithData:[NSArchiver archivedDataWithRootObject:myString]];


    [theObject setValue:myData forKey:@"memoData"];

[gvRegionMapController removeObject:[[gvRegionMapController selectedObjects] objectAtIndex:0]];
[gvRegionMapController addObject:theObject];


    [theObject release];
    [myData release];

    [self saveData];
    return;

---------------------------------------------------
2) The MOC (before Save):

(gdb) po [managedObjectContext updatedObjects] {abridged}
...
<NSCFSet: 0x371d40> (<MapManagedObject: 0x383c30> (entity: Map;... ; data: {
city = nil;
coordinates = nil;
country = nil;
image = "(...not nil..)";
imageData = <040b7479 ...>;
memo = nil;
memoData = <040b7479 ... 626a>; <-- *** here's the binary****.
name = "Central Europe";
province = nil;
region = 0x1414380 <x-coredata://.../Region/p102>;
url = nil;
...
-----------------
3) After the Save in XML: (no 'memo'):
...
<object type="MAP" id="z105">
<attribute name="name" type="string">Central Europe</attribute>
<attribute name="imagedata" type="binary">BAt0eXBlZHN0....
</attribute>
<relationship name="city" type="1/1" destination="CITY"></ relationship>
<relationship name="country" type="1/1" destination="COUNTRY"></relationship>
<relationship name="province" type="1/1" destination="PROVINCE"></relationship>
<relationship name="region" type="1/1" destination="REGION" idrefs="z102"></relationship>
</object>
...


On Jan 30, 2006, at 10:38 AM, Matt Neuburg wrote:



Accepting that for some reason you don't want to use bindings up front (at
least I assume you don't, since you say this NSTextView is unbound), why not
just do it the old-fashioned way? Simply call the MO's setValue:forKey: as
necessary. You will presumably want some way of knowing when it is time to
do this, so you'll probably want to set up a delegate for the text view (or
in some other way get a signal from the interface). m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>






_______________________________________________ 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
References: 
 >Re: programmatically updating an MO's attribute/field (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: I think I have found a big bug in NSBrowser
  • Next by Date: Re: Fake NSMenu-like view
  • Previous by thread: Re: programmatically updating an MO's attribute/field
  • Next by thread: Minimize terminates application
  • Index(es):
    • Date
    • Thread