- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"inventoryItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.textLabel.font = [UIFont systemFontOfSize:15];
}
UILabel *name = (UILabel *)[cell viewWithTag:1];
NSLog(@"%@", name.text);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return inventoryItems.count;
}
I realize this is to do with the dequeueReuasableCellWithIdentifier but I am unsure on how to solve this. I have the textfield on storyboard and then I have an action to send all these textfields with respect to their cells to a database. The code for the textfield is in the IBAction to send the data and am storing. I will add the IBAction code :
- (IBAction)submitCountTapped:(id)sender {
NSMutableDictionary *dic;
if(inventoryItems.count>0){
NSMutableArray *prods = [[NSMutableArray alloc] init];
for (int a=0; a<inventoryItems.count; a++) {
if([inventoryItems[a] objectForKey:@"InventoryID"]!=nil){
UITableViewCell *cell = [_tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:a inSection:0]];
UITextField *countTextfield = (UITextField *)[cell viewWithTag:4];
double countValue = [countTextfield.text doubleValue];
NSNumber *count = [NSNumber numberWithDouble:countValue];
dic = [NSMutableDictionary dictionaryWithObjectsAndKeys: [self fetchDict:@"CustomerData"][@"User_ID"], @"User_ID", count, @"manual_quantity", inventoryItems[a][@"InventoryID"], @"InventoryID", nil];
[prods addObject:dic];
}
}
NSDictionary *outerDic = @{@"Data":prods};
if([self isInternet]){
[self fetchPostAddress:[NSString stringWithFormat:@"http://localhost/Backend/webservice/set-inventory-manually.php"] andParameter:[self jsonconvert:outerDic]andIdentifier:@"manualInventory"];
}
}
}