在我的项目中,我在NSMutableDictionary
上显示UITableview
的值。它工作正常。在我的UITableView
我也有一个编辑button
。我唯一想要的是当我点击编辑button
时,整个数据将显示在下一个视图中。
必须在编辑视图中显示的值将基于Key-' id'。
请帮助我了解如何获得Key-' id'的价值。并在第二个视图上使用它来显示详细信息。
我使用以下代码:
-(void)physiciandata
{
NSString *post = [NSString stringWithFormat:@"data[Users][ref_id]=%@&api_key=bf45c093e542f057c123ae7d6",refidstr];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://192.168.0.20/hsch/api/user_procedure_list"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
[request setHTTPBody:postData];
NSString *str=[[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"str : %@",str);
NSDictionary *dict6 = [self cleanJsonToObject:responseData];
//NSLog(@"str : %@",dict6);
physiciandict = [[[dict6 objectForKey:@"procedure"] objectAtIndex:0] objectForKey:@"PhysiciansProcedures"];
physiciandict1 = [[[dict6 objectForKey:@"procedure"] objectAtIndex:0] objectForKey:@"Procedures"];
//diagnosedictforname = [[[dict6 objectForKey:@"diagnoses"]objectAtIndex:0]objectForKey:@"Diagnoses"];
NSLog(@" for ref id =%@ , data is= %@ , and %@ " ,refidstr, physiciandict , physiciandict1);
CompletephyDic = [physiciandict mutableCopy];
[CompletephyDic addEntriesFromDictionary:physiciandict1];
NSLog(@"Complete data is %@",CompletephyDic);
}
这是我在tableView上显示数据的代码
{
NSString *strid = [physiciandict objectForKey:@"id"];
serialnmbrphysician.text = @"";
serialnmbrphysician.text = strid;
serialnmbrphysician.backgroundColor = [UIColor lightGrayColor];
NSLog(@"data1 %@",strid);
NSString * strName= [CompletephyDic objectForKey:@"procedure_name"];
procedurename.text = @"";
procedurename.text = strName;
procedurename.backgroundColor = [UIColor lightGrayColor];
NSLog(@"data2 %@",strName);
NSString *strName2 = [CompletephyDic objectForKey:@"procedure_code"];
procedurecode.text = @"";
procedurecode.text = strName2;
procedurecode.backgroundColor = [UIColor lightGrayColor];
NSLog(@"data3 %@",strName2);
NSString *strName3 = [physiciandict objectForKey:@"charge_amt"];
averagemedicareallowedamount.text = @"";
averagemedicareallowedamount.text = strName3;
averagemedicareallowedamount.backgroundColor = [UIColor lightGrayColor];
NSLog(@"data4 %@",strName3);
NSString *strName4 = [physiciandict objectForKey:@"total_amt"];
avgsubmittedchargeamount.text = @"";
avgsubmittedchargeamount.text = strName4;
avgsubmittedchargeamount.backgroundColor = [UIColor lightGrayColor];
NSLog(@"data5 %@",strName4);
NSString *strName5 = [physiciandict objectForKey:@"medicare_amt"];
avgmedicarepaymentamount.text = @"";
avgmedicarepaymentamount.text = strName5;
avgmedicarepaymentamount.backgroundColor = [UIColor lightGrayColor];
NSLog(@"data6 %@",strName5);
}