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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -