CoreData transient properties and updateRemote

22 views
Skip to first unread message

Eric

unread,
Apr 11, 2011, 1:18:40 AM4/11/11
to ObjectiveResource
I'm currently using Objective Resource along with Core Data. My main
strategy is that I've got a shared subclass called ORManageObject that
inherits from NSManagedObject in which I've put a lot of syncing logic
(to sync all objects of a given entity description, to sync partials
by date and to sync only some properties when getting the whole list
versus getting the entire object when viewing detail pages).

One catch that I've had to deal with in working with Core Data is
object relationships. For better or worse, I've chosen to deal with
this by marking all the relationships as transient in Core Data, so
that none of them persist in my local store and then I've implemented
each of them as lookups against the ID value.

Anyway, all of this works so far... but I've finally started to look
into what it will take to update the Rails site. From what I can tell
it appears that Objective Resource is discovering all my properties,
including the ones that are transient and don't need to be synced. It
is then following the path down those and collecting additional
properties that aren't required.

I've looked at the source code a bit, and I see some references to
exclusions, but I don't see a way to restrict it to one level. Do I
have to do more manual uploading, or there a technique I can use to
have it be more automagical? If I have to build the XML object to
upload myself I can do that... I'm currently only supporting editing
for one entity, the other 20 or so are all read-only at this time.

Thanks!
Eric

John Pope

unread,
Apr 12, 2011, 1:03:25 AM4/12/11
to objectiv...@googlegroups.com
Hi Eric,

In NSObject-ObjectiveResource.m
you can override the properties by adding relevant property names to excludedPropertyNames array.

Can I ask what benefits you've had from caching with core-data?
There is a fork of this project called objective core data resource or something like that......I'm not sure what mileage that is getting.

The reason I ask is I believe a simpler approach / implementation for caching which would probably give the same benefits. The basic pseudo code being to cache the html payload (json) data to RAM and assign an associated url key. I've already implemented this in HTTPRiot with great results. Subsequent fetches still use all the mechanics and logic of parsing the data they just load it from the cache.

  

Regards
John Pope



/*

 Override this in your model class to extend or replace the excluded properties

 eg.

 - (NSArray *)excludedPropertyNames

 {

  NSArray *exclusions = [NSArray arrayWithObjects:@"extraPropertyToExclude", nil];

  return [[super excludedPropertyNames] arrayByAddingObjectsFromArray:exclusions];

 }

*/


- (NSArray *)excludedPropertyNames

{

// exclude id , created_at , updated_at

return [NSArray arrayWithObjects:[self getRemoteClassIdName],@"createdAt",

@"updatedAt",

@"URLValue",

@"panoramaID",

@"accessibilityLanguage",

@"accessibilityFrame",

@"accessibilityTraits",

@"accessibilityHint",

@"accessibilityValue",

@"accessibilityLabel",

@"isAccessibilityElement",

nil]; 

}





--
You received this message because you are subscribed to the Google Groups "ObjectiveResource" group.
To post to this group, send email to objectiv...@googlegroups.com.
To unsubscribe from this group, send email to objectiveresou...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/objectiveresource?hl=en.


Eric

unread,
Apr 12, 2011, 9:48:09 AM4/12/11
to ObjectiveResource
Thanks! I half found this about an hour before you posted, but I
didn't see that there was an easy override, thanks for pointing that
out... I'll re-factor my hokey solution with this one.

A far as why I'm using core data... I think I started with that mostly
because I'm pretty familiar with it (I was very sad when then first
iOS SDK didn't have it). It manages dependencies between keys and
implements simple getter/setter methods for me in addition to the
persistence.

Anyway, as for if it's easier or harder than just caching the data in
the "raw" form, I can't say. I've only tried it this way. :-) I do
fear that I'm reinventing the wheel sometimes, but so far it's working
well. Honestly, even if I did it that way I think I'd still have that
problem since I have some joins between object types that I'm doing
manually (long story) and I need to prevent this library from
traversing down paths that would lead to infinite loops.

Thanks again! This really is a great library, it's saved me a ton of
time, even when it takes me a bit to figure out quirks (of my data)
that I have to work around.

Eric

On Apr 11, 10:03 pm, John Pope <jdpope2...@gmail.com> wrote:
> Hi Eric,
>
> In NSObject-ObjectiveResource.m
> you can override the properties by adding relevant property names to *
> excludedPropertyNames* array.
Reply all
Reply to author
Forward
0 new messages