I have three data(date, view, textfield).I use SQLite(FMDB).and,It output to tableview. When you run this code, the same cell is output in all sections.I want to textfield and view in a cell for each date.I'm beginner,please tell me.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
titleArry = [[NSMutableArray alloc] init ]; //タイトルを格納するための可変配列
dateArray = [[NSMutableArray alloc] init ]; // 日付格納する可変配列
contentsArry = [[NSMutableArray alloc] init ]; //画像を格納するための可変配列
[DataModel selectTitle:titleArry];
[DataModel selectDateTitle:dateArray];
[DataModel selectContents:contentsArry];
NSMutableSet *mutableSet = [NSMutableSet setWithArray:dateArray]; // 日付の重複を取り除く
array = [mutableSet allObjects];
[table reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return array.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return contentsArry.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
}
//セルに表示する内容
cell.textLabel.text = [titleArry objectAtIndex:indexPath.row];
cell.imageView.image = [[UIImage alloc] initWithData:[contentsArry objectAtIndex:indexPath.row]];
return cell;
}