ios - Save objects with many redundant information (with core data) -


i designing app in objective-c uses core data structure.

i have following structure :

@interface classa : nsmanagedobject @property(nonatomic, strong) sometype1 * property1; .. @property(nonatomic, strong) sometypen * propertyn; @property(nonatomic, strong) nsset * children; @end 

and

@interface classb : classa @property (nonatomic, strong) classa * parent; @end 

i have following features :

1) each object of classa have many children in classb. (objects in classb don't have children themselves).

2) moreover, objects of classb share many properties in common parent (for instance, can think in cases, property1 differ between object of classb , same property in parent in classa, x in classb x.property2 = x.parent.property2 , on).

3) query database through requests on object of type classa.

i looking way reduce disk memory usage of app storing necessary properties of objects of type classb. instance, keep properties of object of classb set nil unless differs 1 of parent, defining getter of classb :

- (sometypex*) getpropertyx {     if (propertyx) return propertyx;     return parent.propertyx; } 

my questions : 1) going gain disk memory filling database nil values instead of actual values 2) there drawbacks such construction 3) there better ways / design patterns deal issue ?

thanks in advance help.

core data highly optimized. you're trying implement using faulting. faulting , uniquing in docs:

because fault not realized, managed object fault consumes less memory, , managed objects related fault not required represented in memory @ all.

to answer questions…

1) going gain memory filling database nil values instead of actual values

if gain memory approach, it's insignificant.

2) there drawbacks such construction

it adds lots of complexity code base without justification. makes code harder read, understand, , maintain.

3) there better ways / design patterns deal issue

just use core data in way that's easy understand, , let handle optimization unless have clear, measurable need optimize further.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -