• 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
NSData as value in NSManagedObject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSData as value in NSManagedObject


  • Subject: NSData as value in NSManagedObject
  • From: Mikkel Eriksen <email@hidden>
  • Date: Fri, 19 Feb 2010 10:04:39 +0100

I've put a small NSXMLDocument into a Core Data binary property like this:

code:

	NSManagedObject *object = /* ... */
	NSXMLDocument *xmlDoc = /* ... */
	[object setValue:[xmlDoc XMLData] forKey:@"xml"];

When I go to retrieve it, it's wrapped in an array:

(gdb) print-object [object valueForKey:@"xml"]
<NSCFArray 0x12c6460>(
<3c3f786d 6c207665 7273696f 6e3d2231 2e302220 656e636f 64696e67
3d225554 462d3822 3f3e3c6a 6e6c7020 73706563 3d22312e 302b2220
636f6465 62617365 3d226874 74703a2f 2f777777
...etc...

So I end up having to use lastObject to get the actual data:

code:

	NSData *xmlData = (NSData *)[[object valueForKey:@"xml"] lastObject];

	NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:xmlData
								options:NSXMLDocumentTidyXML
								  error:nil];

If I don't use lastObject, I get an exception:

2010-02-17 20:46:47.590 AO[7954:813] *** -[NSCFArray length]:
unrecognized selector sent to instance 0x1371170

I can't find anything in the docs for NSManagedObject or NSData that
would explain this, where do I look?

Regards,

Mikkel
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

  • Prev by Date: Re: selectItemWithObjectValue
  • Next by Date: Re: Hillegass printing challenge
  • Previous by thread: Re: strange crash in NSAccessibility
  • Next by thread: Re: NSData as value in NSManagedObject
  • Index(es):
    • Date
    • Thread