Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 08-05-2011, 10:14 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 47
psilocybin is on a distinguished road
Default core data averages

how can i grab a certain amount of values in an entity..i have an entity for values and a entity for the date
i want to grab a weeks worth of values and a month and a year

any help thanks
psilocybin is offline   Reply With Quote
Old 08-05-2011, 10:40 AM   #2 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

you're asking 2 questions really.
Yes you can set a limit to the number of objects returned by your fetch request but that's not what you want to do.

You want to set up a predicate so that only results between 2 dates are returned. something along the lines of
Code:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date > %@ AND date < %@", someOldDate, [NSDate date]];
[fetchRequest setPredicate:predicate];
This will return all objects where the date of the object falls between somOldDate and now.
sneaky is offline   Reply With Quote
Old 08-05-2011, 10:52 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 47
psilocybin is on a distinguished road
Default

ah thanks...ill work on that
psilocybin is offline   Reply With Quote
Old 08-05-2011, 11:23 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 47
psilocybin is on a distinguished road
Default

is there a resource i can read to interpret this into a pickerview with fetching certain values depending on whats selected? would i have to execute a fetch request for each property in the pickeriew?

Last edited by psilocybin; 08-05-2011 at 11:38 AM.
psilocybin is offline   Reply With Quote
Old 08-05-2011, 11:58 AM   #5 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

Quote:
Originally Posted by psilocybin View Post
is there a resource i can read to interpret this into a pickerview with fetching certain values depending on whats selected? would i have to execute a fetch request for each property in the pickeriew?
well....
What have you got in your pickerview???
usually if you have a pickerview you'd have 1 array per spinner. you may have to do one fetch per spinner depending on what your data looks like.

But I really can't tell without more information
sneaky is offline   Reply With Quote
Old 08-05-2011, 12:33 PM   #6 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 47
psilocybin is on a distinguished road
Default

I have 1 pickerview it contains 1 week, 2 weeks, 3 weeks. Depending on the choice I will be calculating the average of the values within the givin time

Last edited by psilocybin; 08-05-2011 at 12:42 PM.
psilocybin is offline   Reply With Quote
Old 08-05-2011, 01:19 PM   #7 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

So in your picker delegate you will need to create a date to use for the fetch and then do what you need to do with the data
sneaky is offline   Reply With Quote
Old 08-05-2011, 01:32 PM   #8 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 47
psilocybin is on a distinguished road
Default

Can you please explain a bit better? I'm still in the middle stages of learning
psilocybin is offline   Reply With Quote
Old 08-05-2011, 03:09 PM   #9 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

Right, so you spin the picker to 2weeks. Your picker has a delegate method, the delegate will get called when the value of the picker change.

Then you will have to create 2 dates, a from and a to date.

I don't know what you want to do with your data but using the from and the to date above you should be able to fetch the data you're after.

I'm not sure after that what you need help with. Be specific.
sneaky is offline   Reply With Quote
Old 08-05-2011, 03:29 PM   #10 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 47
psilocybin is on a distinguished road
Default

BasicLly I just need help with that delegate method. I'm getting the values from those days and calculating the sum
psilocybin is offline   Reply With Quote
Old 08-05-2011, 05:07 PM   #11 (permalink)
Token farm animal
 
sneaky's Avatar
 
Join Date: Apr 2011
Posts: 321
sneaky is on a distinguished road
Default

So look up uipickerview delegate protocol and check what methods could apply to what you want to do. Hint, you'll get an index.

You will have to create the dates. Loop up how to create a date from components. You can use an offset from the current date.

I've used a good few keywords here now. Google is your friend
sneaky is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 391
16 members and 375 guests
Absentia, bignoggins, Diligent, dre, epaga, hussain1982, jbro, LunarMoon, momolgtm, Newbie123, omagod, Paul10, pinacate, revg, skog, taylor202
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,859
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:49 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0