Re: Core Data: Unable to store a NSData object into an entity's binary property.
Re: Core Data: Unable to store a NSData object into an entity's binary property.
- Subject: Re: Core Data: Unable to store a NSData object into an entity's binary property.
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 6 Jan 2006 14:36:58 -0800
On Jan 6, 2006, at 2:05 PM, Frederick C. Lee wrote:
NSManagedObject *map = [[NSManagedObject alloc] init];
Why are you doing this? You're leaking this instance.
Moreover, you should *not* use the 'init' method to initialise
managed objects:
<http://developer.apple.com/documentation/Cocoa/Reference/
CoreData_ObjC/Classes/NSManagedObject.html#//apple_ref/occ/instm/
NSManagedObject/initWithEntity:insertIntoManagedObjectContext:>
map = (NSManagedObject *)[NSEntityDescription
insertNewObjectForEntityForName:@"Map"
inManagedObjectContext:managedObjectContext];
[map setValue:[NSString stringWithFormat:@"%@ Map",inRegion]
forKey:@"name"];
NSData *myData = [NSData dataWithContentsOfFile:@"/Users/Ric/
Library/Application Support/Eccron/Maps/tiff/Europe1.tif"];
if (myData)
[map setValue:myData forKey:@"imageData"];
[regionMaps addObject:map];
[map release];
You should not be releasing 'map' here --
insertNewObjectForEntityForName returns an autoreleased object:
<http://developer.apple.com/documentation/Cocoa/Reference/
CoreData_ObjC/Classes/NSEntityDescription.html#//apple_ref/occ/clm/
NSEntityDescription/
insertNewObjectForEntityForName:inManagedObjectContext:>
Can anyone explain why a NSData object doesn't get stored in a
entity binary attribute?
In your earlier messages, you indicated you might be overriding the
accessor methods -- is this still the case?
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