iOS使用Plist中的数据填充UITableView
我想用我的Data.plist
文件的内容填充一个UTTableView
。 我需要加载到一个NSMutableArray
。 这是我来了多远:
(查看加载):
NSString *PlistPath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"]; Array = [[NSMutableArray alloc] initWithContentsOfFile:PlistPath]; [Array addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Testing 1", @"name", nil]];
当然,在CellForRowAtIndexPath
:
cell.textLabel.text = [Array objectAtIndex:indexPath.row];
我写在我的Data.plist
文件(图片):
现在,当我运行该应用程序。 我的TableView
保持空白。
感谢您的时间和帮助!
目前你的plist的根目录设置为Dictionary
。 首先将其更改为array
。
然后使用这个代码来显示数据:
cell.textLabel.text = [[Array objectAtIndex:indexPath.row] objectForKey:@"name"];