我在表格视图中有两个部分,当用户单击任何单元格时,它会显示详细数据,但问题是当用户从第一部分选择任何选项时,它会显示索引 3,而从第二部分开始,它只显示 6,我有 3 个值在每个部分中,我希望当我单击索引时它可能会显示索引值而不是最后三个值
contentID 为所有平均最后值显示 3
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ObjectData *theCellData = [resultArray objectAtIndex:indexPath.row];
userName=@"Jamshed";
contentID=theCellData.content_ID;
status=@"On";
NSString*type=theCellData.content_Type;
if ([type isEqualToString:@"Video" ])
{
[self playVideo];
}
}
-(void)addToLearning{
NSLog(@"Content ID Learning %@",contentID);
NSDate *StrDate = [NSDate date];
NSDateFormatter *Dateformat = [[NSDateFormatter alloc]init];
[Dateformat setDateFormat:@"DD-MM-YYYY HH:mm:SS"];
NSMutableString *DateStr = [Dateformat stringFromDate:StrDate];
addedDate=DateStr;
NSString *post =[[NSString alloc] initWithFormat:@"user_Name=%@&content_ID=%@&added_Date=%@&status=%@",userName,contentID,addedDate,status];
NSURL *url=[NSURL URLWithString:@"http://www.celeritas-solutions.com/pah_brd_v1/productivo/myLearning.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",data);
}