• 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
Fetch Requests on Non Standard Classes in Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fetch Requests on Non Standard Classes in Core Data


  • Subject: Fetch Requests on Non Standard Classes in Core Data
  • From: Ian Peters-Campbell <email@hidden>
  • Date: Wed, 13 May 2009 20:41:01 -0700

Hey all,

I'm fairly new to iPhone/Cocoa, and brand new to Core Data.  I'm in the
process of writing a data manager, and I would like it to use Core Data.
Unfortunately my brain is breaking a little bit with a conceptual issue.  I
need an entity which will store some binary data along with a guid (a 16
byte int) for indexing/lookup.  This in itself is a little bit harrowing,
since I don't see any native support for 16 byte ints in Core Data.

To make matters worse though, the guid is wrapped in what is effectively a
container class which includes network serialization functionality, an
isEqual method, etc along with the 16 bytes of guid data.  If possible I
would like to store the wrapper object in Core Data rather than extracting
data from it and then rebuilding it each time I store/retrieve the object.
It seems eminently possible to do the actual storage/retrieval using an
NSValueTransformer with a Transformable attribute, but what is hurting my
brain is the idea of lookups.  How (if at all) can I store these wrapper
objects in such a way that I can do fetch requests based on their internal
values?

That is, if I have an object:

wrapperA:
    guidBytes "1111222233334444"

And I have already stored two entities in Core Data with something like

EntityInstanceA:
    binaryData: foo
    accessDate: bar
    guidInstance:
        guidBytes: "1111222233334444"


EntityInstanceB:
    binaryData: baz
    accessDate: quz
    guidInstance:
        guidBytes: "4444333322221111"

Is it possible for me to do a fetch request using the guidBytes inside
wrapperA to return me EntityInstanceA with its matching guidBytes, which are
stored as a member of a class which is "blobbed" into an entity attribute?

Wow, I hope that all makes sense.

Possible solutions I have now are
- to save the guid bytes as an additional string attribute in the entity and
just key off that (like an id column) but that seems like it's storiing
extra data.
- to not save the wrapper object at all, just the inner byes, and rebuild
the wrapper each time I do a fetch, but that seems less efficient than I
would like and means i can't just return the fetched entity to the requestor
without also returning one of the wrapper objects.

Ideas?  Suggestions?  Rollings of eyes?  Pitchforks and torches?
_______________________________________________

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

  • Follow-Ups:
    • Re: Fetch Requests on Non Standard Classes in Core Data
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Class Singleton Instantiation
  • Next by Date: Invoice program made in Objective c/Cocoa
  • Previous by thread: Re: NSCFArray autoreleased with no pool in place
  • Next by thread: Re: Fetch Requests on Non Standard Classes in Core Data
  • Index(es):
    • Date
    • Thread