我試圖將NSDictionary數據放入表視圖中。但是我遇到問題存在價值。將NSDictionary轉換爲UITableView
字典看起來像這樣:使用的XMLReader
multimedia = {
uploads = {
upload = (
{
FileName = {
text = "\n 1-FB5A9792.MOV";
};
status = {
text = "\n 2";
};
Event = {
text = "\n Test";
};
Date = {
text = "\n 9/7/2016 9:06:21 AM";
};
Publicacion = {
text = "\n Example";
};
Seccion = {
text = "\n Sistemas";
};
id = {
text = "\n \n \n 993";
};
text = "\n ";
},
{
FileName = {
text = "\n 2-FB5A9793.MOV";
};
status = {
text = "\n 2";
};
Event = {
text = "\n Test";
};
Date = {
text = "\n 9/7/2016 9:06:21 AM";
};
Publicacion = {
text = "\n Example";
};
Seccion = {
text = "\n Sistemas";
};
id = {
text = "\n \n 994";
};
text = "\n ";
},
{
FileName = {
text = "\n 1-IMG_0006.MOV";
};
status = {
text = "\n 2";
};
Event = {
text = "\n Highest";
};
Date = {
text = "\n 9/7/2016 4:56:37 PM";
};
Publicacion = {
text = "\n Example";
};
Seccion = {
text = "\n Sistemas";
};
id = {
text = "\n \n 995";
};
text = "\n ";
},...
I'm轉換的XML到詞典,則上述數據傳遞到資料表
tableData = [jsonDictionary allKeys];
表
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
創建單元
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
NSString *key = [tableData objectAtIndex:indexPath.row];
NSDictionary *dictionary = [jsonDictionary objectForKey:key];
// get values from the dictionary and set the values for the displayed cell ...
return cell;
}
我試圖爲每個FileName和狀態值放置一個單元格,在這種情況下爲每個FileName放置3個單元格。 但我不知道如何做到這一點或獲得FileName的數量。
這是XML
<multimedia>
<uploads>
<upload>
<id>1136</id>
<Date>9/9/2016 11:01:58 AM</Date>
<FileName>IMG_0510.MOV</FileName>
<status>2</status>
<Publicacion>Example</Publicacion>
<Seccion>Sistemas</Seccion>
<Event>Q</Event>
</upload>
</uploads>
</multimedia>
是那個'jsonDictionary'的輸出?或者顯示分配給'jsonDictionary'的值。 –
是的,是jsonDictionary日誌,'NSLog(@「%@」,jsonDictionary);' – CGR
''jsonDictionary.count'輸出什麼' –