objective c - CoreData Entity Fetch Request -
i have entity called timeinterval
attributes startdate
, finishdate
, type date. not need add attribute called totaltime
because can calculated doing: [finishdate timeintervalsincedate: startdate]
can create fetched property attribute totaltime
? if not best way go without having add totaltime attribute seems redundant.
i new core-data way.
you can separate property (or full-on transient attribute if like).
consider this...
@interface item : nsmanagedobject @property (nonatomic, readonly, assign) nstimeinterval totaltime; @end @implementation item - (nstimeinterval)totaltime { [self willaccessvalueforkey:@"totaltime"]; nsdate *finishdate = [self primitivefinishdate]; nsdate *startdate = [self primitivestartdate]; nstimeinterval result = [finishdate timeintervalsincedate: startdate]; [self didaccessvalueforkey:@"totaltime"]; return result; } @end
Comments
Post a Comment