这是我的问题。
我似乎无法弄清楚如何访问"详细信息"键入与"名称"相同的级别;密钥一旦搜索特定的名称密钥。也许我错过了什么?
我知道你可以得到"细节"通过 private void btnUpload_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
string strSelect = "SELECT serial, upc, man_date, location, product, created_by, created_date, serial from schema.table where rownum < 2";
string strInsert = "INSERT INTO schema.table (serial, upc, man_date, location, product, created_by, created_date, serial) VALUES (:serial, :upc, :man_date, :location, :product, :created_by, :created_date, :serial)";
string conStr = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
OracleConnection connection = new OracleConnection(conStr);
connection.Open();
if (connection.State != ConnectionState.Open)
{
return;
}
OracleDataAdapter adapter = new OracleDataAdapter(strSelect, conStr);
OracleCommandBuilder builder = new OracleCommandBuilder(adapter);
adapter.Fill(dt);
dt.Columns["SERIAL"].Unique = true;
dt.Merge(dtUpload);
dt.Rows.Remove(dt.Rows[0]);
foreach (DataRow row in dt.Rows)
{
row.SetAdded();
}
try
{
adapter.Update(dt);
}
catch (Exception ex)
{
string x = ex.Message + ex.StackTrace;
throw;
}
finally
{
connection.Close();
connection.Dispose();
}
}
,但我不确定如何获得与搜索到的相同级别的那个。
代码:
[dict objectForKey:@"Details"]
plist中:
- (IBAction)ScoringButtonView:(id)sender {
ScoringViewController *svController = [[ScoringViewController alloc] initWithNibName:@"ScoringView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:svController animated:YES];
UIButton *scoringButton = (UIButton*)sender;
NSLog(@"Scoring is %@ ", scoringButton.currentTitle);
svController.ScoringName = scoringButton.currentTitle;
NSString *path = [[NSBundle mainBundle] pathForResource:@"Scoring" ofType:@"plist"];
NSArray *plistData = [NSArray arrayWithContentsOfFile:path];
for (NSDictionary *dict in plistData) {
if ([[dict objectForKey:@"Name"] isEqualToString:scoringButton.currentTitle]) {
NSLog(@"Scoring == %@ ", scoringButton.currentTitle);
// svController.ScoringInfo =
}
}
答案 0 :(得分:0)
我不确定是什么混淆。您已经知道如何获取Name
密钥的值。获取Details
密钥的值是相同的:
for (NSDictionary *dict in plistData) {
if ([dict[@"Name"] isEqualToString:scoringButton.currentTitle]) {
NSString *details = dict[@"Details"];
}
}
请注意我是如何使用现代Objective-C语法而不是使用objectForKey:
的旧样式。
答案 1 :(得分:0)
//此方法应该可以正常工作
//枚举方法优于循环
NSString *filePath = [[NSBundle mainBundle] pathForResource:@“LanguageList” ofType:@"json"];
NSString *myJSON = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSJSONReadingAllowFragments error:NULL];
NSError *error = nil;
NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:[myJSON dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
[dict[@"result"] enumerateObjectsUsingBlock:^(id _Nonnull objList, NSUInteger idx, BOOL * _Nonnull stop) {
NSLog(@“Values %@”,obj);
*stop = YES;
}
}];