• 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: Unable to store a NSData object into an entity's binary property.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Core Data: Unable to store a NSData object into an entity's binary property. (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: NSTextView unarchived from nib missing pointing hand cursor over links?
  • Next by Date: Re: NSTextView unarchived from nib missing pointing hand cursor over links?
  • Previous by thread: Core Data: Unable to store a NSData object into an entity's binary property.
  • Next by thread: Core Data: Unable to store a NSData object into an entity's binary property.
  • Index(es):
    • Date
    • Thread