• 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: Core Data Binding: Unable to store a binary image (TIFF)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data Binding: Unable to store a binary image (TIFF)


  • Subject: Re: Core Data Binding: Unable to store a binary image (TIFF)
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Thu, 5 Jan 2006 15:50:45 -0800

Greetings:

I'm still trying to I/O NSImage data from a persistent store. But first I must actually STORE an image NSData object.

This time I manually populated the [region] -->> [map]; and then retrieve the data via IB NSArrayController.
The text field retrieval is ok. BUT I DON'T GET THE NSIMAGE.


Problem: Unable to store NSDATA binary.   -- What's missing here?

(abridged) Scenario:
	[region] --->> [map]
map entity:
         name - string
         image - unknown format --> NSImage
         imageData - binary
         region - inverse link to parent [region]
         country - inverse link to parent [country]
         city - inverse link to parent [city]
============================
Front End.
The IB Binding appears to be correct:

[Maps Controller] contentSet = selection.map[Region Array Controller (NSArrayController)]
[Region Array Controller] --> ManagedObjectContext [File's Owner (NSPersistentDoc)].


value = selection.name[Maps(NSArrayController)] --> NSTextField *ok*
value = selection.image[Maps(NSArrayController)] ---> NSImageView *nothing*


============================

1) I stuff a NSData image into the Map entity's imageData field:

NSData *encodedMap = [[gvNewMapView image] TIFFRepresentation];
...
if (encodedMap) {
NSMutableSet *regionMaps = [region mutableSetValueForKey:@"map"]; // Region:Maps --> 1:many
NSManagedObject *map = [[NSManagedObject alloc] init];
map = (NSManagedObject *)[NSEntityDescription insertNewObjectForEntityForName:@"Map"
inManagedObjectContext:managedObjectContext];
[map setValue:[NSString stringWithFormat:@"%@ Map",inRegion] forKey:@"name"];
[map setValue: encodedMap forKey:@"imageData"];
[regionMaps addObject:map];
[map release];
}
....
if ([managedObjectContext save:&error]) NSLog(@"{addNewEntry}. Save *Success*");
....
=============================
2) Data Check via debugger:


(gdb) po [encodedMap class]
NSConcreteData
(gdb) print (int) [encodedMap length]
$1 = 156696


(gdb) po map
<GVManagedObject: 0x4818e20> (entity: Map; id: 0x4818e60 <x- coredata:///Map/t6B7E3D70-A3F4-4B34-A2FA-FE61FE2B13D3> ; data: {
city = nil;
country = nil;
image = nil;
imageData = "(...not nil..)";
memo = nil;
name = "Europe Map";
region = 0x4818230 <x-coredata:///Region/t3812A878- DEC7-45E2-8D26-8BD0474F1D88>;
subregion = nil;
})


==============================
3) Notice the ABSENCE of map.image binary data:

(gdb) po [[[managedObjectContext insertedObjects] anyObject] valueForKeyPath:@"map.name"]
<NSCFSet: 0x481dfd0> (Europe Map)
(gdb) po [[[managedObjectContext insertedObjects] anyObject] valueForKeyPath:@"map.image"]
<NSCFSet: 0x481e330> ()


==============================
4) The output file:

<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "file:///System/Library/DTDs/CoreData.dtd">

<database>
<databaseInfo>
<version>134481920</version>
<UUID>B743B41F-F2AD-48B4-BCFA-29FF7465FD64</UUID>
<nextObjectID>103</nextObjectID>
<metadata></metadata>
</databaseInfo>
<object type="REGION" id="z102">
<attribute name="name" type="string">Europe</attribute>
<relationship name="country" type="0/0" destination="COUNTRY"></relationship>
<relationship name="map" type="0/0" destination="MAP" idrefs="z103"></relationship>
</object>
<object type="MAP" id="z103">
<attribute name="name" type="string">Europe Map</attribute>
<relationship name="city" type="1/1" destination="CITY"></ relationship>
<relationship name="country" type="1/1" destination="COUNTRY"></relationship>
<relationship name="region" type="1/1" destination="REGION" idrefs="z102"></relationship>
<relationship name="subregion" type="1/1" destination="SUBREGION"></relationship>
</object>
</database>



-- why doesn't the NSData get written to persistent store??

Thanks for your expertise!
Ric.
_______________________________________________
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


  • Prev by Date: Re: Bindings Problem
  • Next by Date: Re: netService:didNotPublish: gets called with NSNetServicesErrorCode -65548
  • Previous by thread: Re: Bindings Problem
  • Next by thread: Re: How to create Daemon for Mac 10.
  • Index(es):
    • Date
    • Thread