ios - Core Data and NSSortDescriptor - memory basics -
i'm trying sort on core data entity's relation. instance there employee object , has departments relationship.
- i nsfetchrequest of employee
- i write method take out
departments
(nsset
) , gets me sorted departments
the code i'm using following.
[temparray sortedarrayusingdescriptors:[nsarray arraywithobject:sortdescriptor]];
i see memory getting retained after sometime , core data object in getting retained after long time.
i removed line thinking reason
//[moc setretainsregisteredobjects:yes];
but not helping. want understand objects method on nsset
of core data object cause bump in memory , sortedarrayusingdescriptors
deep copy? know shallow copy, please confirm , logical reason memory getting retained after usage of array of object got using sortedarrayusingdescriptors
.
as stated in comment, should provide context question. so, did see behavior in instrument?
anyway, instead of fetching , sorting, can fetch and, @ same time, sort (through nsfetchrequest
using setsortdescriptors:
) against department
based on specific predicate (if understood problem predicate give departments belong specific employee). in way sorting done @ sql level.
you should provide code using concerning
[temparray sortedarrayusingdescriptors:[nsarray arraywithobject:sortdescriptor]];
what sortdescriptor
? if not using arc, alloc-init
new sortdescriptor
must dealloc it. otherwise have leak.
Comments
Post a Comment