중첩 된 사전을 사용하여 테이블 뷰에 데이터를 제공하는 iOS 앱이 있습니다. 사전의 구조는 다음과 같습니다.중첩 된 사전의 단일 요소 액세스
Dictionary<string1, Dictionary<string2, string3>> dict;
(I have named the strings here for clarification purposes)
이 중첩 된 사전의 단일 요소에 액세스하는 데 현재 문제가 있습니다. string1
을 섹션 제목으로 사용하려면 string2
을 셀 텍스트 레이블로, string3
을 셀 세부 텍스트 레이블로 지정하고 싶습니다.
public class SupervisionDetailSource:UITableViewSource
{
Dictionary<string, Dictionary<string, string>> dict;
string Identifier = "cell";
public SupervisionDetailSource(Dictionary<string, Dictionary<string, string>> dict)
{
this.dict = dict;
}
public override string TitleForHeader(UITableView tableView, nint section)
{
return dict.Keys.ElementAt((int)section);
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(Identifier);
if (cell == null)
cell = new UITableViewCell(UITableViewCellStyle.Subtitle, Identifier);
//this is not right
cell.TextLabel.Text = dict[supvList.Keys.ElementAt(indexPath.Section)][dict[dict.Keys.ElementAt(indexPath.Row)]]; //string2
cell.DetailTextLabel.Text = string3 ...?
return cell;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
string key = dict.Keys.ElementAt((int)section);
return dict[key].Count;
}
public override nint NumberOfSections(UITableView tableView)
{
return dict.Keys.Count;
}
}
어떤 도움
당신이 "옳지 않다"무엇을 의미합니까? – Alexander
@AMomchilov 제 사전의'string2'에 대한 현재 접근법이 옳지 않거나 컴파일 할 수 없음을 의미합니다. – panthor314
아무 것도 말해주지 않은 것 같습니다. 컴파일러 오류입니까? 그렇다면 오류 메시지는 무엇입니까? 런타임 오류입니까? 그렇다면 스택 트레이스는 무엇입니까? 논리적 오류입니까? 그렇다면 실제 출력과 예상 출력은 무엇입니까? – Alexander