Re: Tree rest resource and sorting

"David Steinberger" <[email protected]>
Newsgroups gmane.comp.web.gallery.devel
Message-ID <[email protected]>
Best doc is the one from Apple:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html#//apple_ref/doc/uid/TP40001802-CJBDBHCB

See 'How do I fetch objects in the same order I created them?' about collections and core data.

I'm using core data 90% via RestKit: https://github.com/twotoasters/RestKit

If you want checkout the example 'RKTwitterCoreData' to see how it works (branch 67-object-mapping-2.0).
I can also send a mockup how I mapped gallery3 json responses (tree & item).

-------- Original-Nachricht --------
> Datum: Sun, 5 Jun 2011 16:44:49 -0700
> Von: Bharat Mediratta <[email protected]>
> An: David Steinberger <[email protected]>
> CC: [email protected]
> Betreff: Re: [Gallery-devel] Tree rest resource and sorting

> On Sun, Jun 5, 2011 at 3:44 PM, David Steinberger
> <[email protected]>wrote:
> 
> >
> > Right after I sent the message I realized that I'd be beaten up by that.
> >
> > So let me give details: Core Data doesn't store NSArray, but NSSet:
> >
> >
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSSet_Class/Reference/Reference.html
> >
> > Yes it's platform specific. but right now iOS is the most common one.
> > Core Data is the best way to serialize objects (IMHO) and I really want
> to
> > use it.
> >
> 
> Ok.  I'm reading through the Core Data docs, but I'm new to it and there
> are
> a ton of docs out there.  Can you point me at relevant docs that talk
> about
> how Core Data does its underlying storage?
> 
> I assume that at some point you're going to coerce the NSSet into an
> NSArray
> by applying a sort order over the given field.  But it's a little
> surprising
> that the initial ordering isn't preserved somewhere...
> 
> 
> >
> > Why should it be wrong to indicate the sort by an attribute?
> > It doesn't impact the server-side at all.
> >
> 
> But it doesn't belong on the server side, either.  We're already sending
> an
> ordered list -- adding an ordering field is redundant.  This is really a
> limitation on the client side and it should be fixed there.  Yes, I'm
> being
> a bit of a purist but I hate crapping up our APIs to handle edge cases. 
> If
> this is the only way to do it, I'll be grumpy but I'll fiddle with the
> server side code.  But I'd like to be convinced that there  isn't some way
> to do it in Core Data.  Surely this must be a common use case.
> 
> 
> >
> >
> > On 6/6/11 12:16 AM, Bharat Mediratta wrote:
> >
> >
> >  Hm.  An array is an ordered list, and I would expect NSArray to
> maintain
> > the ordering --
> >
> http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html seems
> > to bear that out.  Are you seeing it lose the ordering?
> >
> >  Even if it was, I'd expect that this is a platform specific problem so
> > I'd expect it'd be something you'd fix on your side by updating the
> entity
> > after you load it.  Doing it on the server side smells wrong to me.
> >
> >  Thoughts?
> >
> > On Wed, Jun 1, 2011 at 10:55 AM, David Steinberger
> <[email protected]>wrote:
> >
> >>  Team,
> >>
> >> I'm reworking the data model of my iPhone app.
> >> One thing I want to revisit is how I deal with the tree rest resource
> >> (tree_rest.php).
> >>
> >> Reason:
> >> I know that the tree_rest.php delivers the objects in the right order,
> but
> >> this doesn't help me much.
> >> I need to store and retrieve the array and by doing such an operation
> with
> >> an array the order might be lost.
> >>
> >> Proposed solution:
> >> The patch attached adds a relative_position attribute to each entity.
> Via
> >> this attribute the entity order can be reconstructed at any time.
> There's no
> >> impact on performance and overall structure.
> >>
> >> Please review and merge to master or propose something even better.
> >>
> >> Thanks,
> >>   David
> >>
> >> ---
> >>
> >> FYI Details:
> >> I use core data to cache all objects (tree/album, items, tags, ...).
> Core
> >> data is kind of a database for objects on iOS. The tree is modeled via
> a
> >> Class that has a NSString property that holds the url (that's the
> primary
> >> key) and a NSArray that holds all the entities.
> >> But when I retrieve the object-graph iOS applies any sorting. ==> A
> >> sort-attribute is needed.
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> Simplify data backup and recovery for your virtual environment with
> >> vRanger.
> >> Installation's a snap, and flexible recovery options mean your data is
> >> safe,
> >> secure and there when you need it. Data protection magic?
> >> Nope - It's vRanger. Get your free trial download today.
> >> http://p.sf.net/sfu/quest-sfdev2dev
> >> __[ g a l l e r y - d e v e l ]_________________________
> >>
> >> [ list info/archive --> http://gallery.sf.net/lists.php ]
> >> [ gallery info/FAQ/download --> http://gallery.sf.net ]
> >>
> >
> >

-- 
NEU: FreePhone - kostenlos mobil telefonieren!			
Jetzt informieren: http://www.gmx.net/de/go/freephone

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today. 
http://p.sf.net/sfu/quest-dev2dev2 
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.