Pleaseeee if you guys can help me or point me on the right direction, I would really appreciate.
I am saving some data the user inputs into a data file using SQLITE, I am saving date, time, reading, and a note, as the following:
//Create a Reading Object Readings *readingObj = [[Readings alloc] initWithPrimaryKey:0]; readingObj.date = date.text; readingObj.time = time.text; readingObj.reading = reading.text; readingObj.note = note.text;
//Add the object //This is where I add the inputs to the SQL data file [appDelegate addReading:readingObj];
My problem or question is: I want to sort the data in a uitableview with date as the section header and other inputs under the section in a cell. The dates represent the number of sections I would have.
This is what I have for now:
(NSInteger)numberOfSectionsInTableView:(UITableVie w * )tableView { return 1; }
(NSInteger)tableView:(UITableView * )tableView numberOfRowsInSection:(NSInteger)section { return [appDelegate.readingsArray count]; }
(UITableViewCell * )tableView:(UITableView * )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
HistoryCell *cell = (HistoryCell * )[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) { cell = [[[HistoryCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; }
//Get the object from the array. Readings *readingObj = [appDelegate.readingsArray objectAtIndex:indexPath.row];
[cell setTodo:readingObj]; return cell; }
readingsArray is the array where I load all the data to; it has all the data:
NSInteger primaryKey = sqlite3_column_int(selectstmt, 0); Readings *readingObj = [[Readings alloc] initWithPrimaryKey:primaryKey]; readingObj.date = [NSString stringWithUTF8String:(char * )sqlite3_column_text(selectstmt, 1)]; ////change to int readingObj.time = [NSString stringWithUTF8String:(char * )sqlite3_column_text(selectstmt, 2)]; //// readingObj.reading = [NSString stringWithUTF8String:(char * )sqlite3_column_text(selectstmt, 3)]; //// readingObj.note = [NSString stringWithUTF8String:(char * )sqlite3_column_text(selectstmt, 4)];
[appDelegate.readingsArray addObject:readingObj]; [readingObj release];
How can I have mutliple sections based on the dates, when I only have one array, which readingsArray that has all the data. couldn't make a dates array cuz it was confusing for me. The dates sections would have multiple readings during that day.
Any suggestions or thoughts pleaseeeeeeeeeee!!!!! I can provide more code or explaination about my code if needed.