Friday, 25 July 2014

calculations in coredata results


i've read multiple tutorials core data of them have basic setup.. hope ill learn more each day it. cuz made somethings simpler. though absolute control sqlite gives bit of tradeoff.. maybe i'm wrong!

here i'm trying fetch things differently..


lets i'm trying record calculate results based on values stored in core data.

lets take enery equation : e=mc(square)

have 3 entities, parent/child/recentrecords

**a category's entity**
category
-name : einstein's equation
-e = mc2

**child entity:**
- name: mass

entry:
- name:lightspeed (for sake of example, lets speed of light not constant.

recent entity: purpose of entity store , track child entities , has:
-nsdate timestamp
-nsnumber: value
-relationship <---->>childentity

i'll explain user's point of view,
if tap "einstain's equation" (category/parent entity), detail view bring out 2 textfields iterating through child entity. when record entries of mass, light speed, should saved in recent entity. overtime can have bunch of recordings.

image similar setup formula, v=u+at. velocity parent. u, a, t in child entity. , in 1 recording user add 3 recent entity objects.

question want find out if theres efficient way calculate results/entries @ parent/category entity level.

because, einstainsequation stores formula of child entities, e=mc2 , v=u+at. thing thats making complicated fetching entries recent entity based on timestamp (recording) , calculating , showing result based on recent entries.


code:
         parent<-------->>child<-------->>recent          -einstein <---->>mass <----------->>multiple mass recordings based on time          -mc2             lightspeed <------>>multiple lighspeed records based on time                    -velocity<------>>u            <--------->>multiple entries based on time of 3.          -u+at             aceleration                            timetaken
based on graph above, need einstein result recent entries of mass/lightspeed , calculate each of entries formula mc2.

thought of having transient property in parent entity, how go accomplishing this? how can use formula , calculate child values of recent entity.

im kinda lost here..
 

i may misunderstanding trying do. think you're trying have core data calculate , simple answer can't.

core data holds data, looking information, information calculated value data.

data - "this post made 2012"
information - "this post posted year"

information outdated next year , have recalculated - have somehow.


want information based on last entry of these. if mass object , light speed object can faulted same einstein object it's gravy. can make calculations in category of enisten object , mass , light speed there.

if not need fetch last light speed object, fetch last mass object - values need each, calculate information need.

in case see no point in keeping einstein object though. create core data entities can add arbitrary number of objects of kind, einstein object more of method?
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment