views:

181

answers:

2

How can i get the date from database and load it onto the UIDatePicker?

ok i will describe my question in detail I am fetching data from SQLite 3 database and that data is fetched onto the RootViewController from the database.Now i want that data to be forwarded to the next view in which i have my UIDatePicker,So the UIDate Picker should display the date from the database. I know how to load the current date and time.

This is the implementation

  • (void)viewDidLoad {

    [super viewDidLoad];

    database =[[Database alloc]init];

    arrMain=[[NSMutableArray alloc]initWithArray:[database SelectName]];

    NSArray *arrTemp=[upStr componentsSeparatedByString:@"|"];

    fname.text =[arrTemp objectAtIndex:3];

    lname.text=[arrTemp objectAtIndex:4];

    designation.text=[arrTemp objectAtIndex:2];

} I get the data from the array onto the textboxes,but i am not able to set the date from the database to the UIDatePicker.I hope u get my question,Thnks for a prompt reply!

A: 

You have two questions here. The first question is "how do I load data from the database". What kind of database do you have? Are you using Core Data? If so, describe the entity you're trying to load.

The section question is "How do I set a UIDatePicker?" Here's an example of setting a UIDatePicker with a datePickerMode value of UIDatePickerModeTime, to the current time:

NSDate* now = [NSDate date];
picker.date = now;
Shaggy Frog
ok i will describe my question in detail I am fetching data from SQLite 3 database and that data is fetched onto the RootViewController from the database.Now i want that data to be forwarded to the next view in which i have my UIDatePicker,So the UIDate Picker should display the date from the database.
aditya
A: 

you have two options. 1. create a variable in the app delegate. 2. create a variable in the second view and set the property. then u can access it from the first view after your initFromNib command.

don the database part. if u have stored the date as a string in the datebase then u wil have to retrieve it a string and then create the date using formatters.

BK