views:

20

answers:

1

I'm trying to let the 'date' populate data to a label.

Example: a work out schedule suppose today is August 5, so the label might read "do 20 pullups" and then on August 6, the same label might read "do 30 pushups". doesn't matter if the data is coming from an SQLite database or simple array.. I just can't figure out how to get the date to drive the data.

Any help would be great. Thanks in advance.

A: 

With all due respect, this is basic computer programming that you should learn by working through some tutorials (in any language). With the iPhone SDK there are a number of ways you can do this. You might start with a simple array where each element of the array corresponds to one of the days.

    NSArray *fred = [NSArray arrayWithObjects:@"20", @"30", @"40", nil];
// A better way is to use NSDateComponents, it's more accurate but a little more complicated
NSDate *numberOfDays = [startDate timeIntervalSinceDate:startDate] / (60 * 60 * 24);
    NSString *label = [NSString stringWithFormat@"do %@ pushups",[fred objectAtIndex:numberOfDays];

Of course you'll need to do error checking etc, but this will get you started.

joelm