[英]Can't get content from plist to UITableview
您好,我收到此错误,但我找不到问题所在
我的代码是这样的:
@implementation ViewController {
NSDictionary *animalDetails;
NSArray *justAnimalNames;
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [[NSBundle mainBundle] URLForResource: @"animals"withExtension:@"plist"];
animalDetails = [NSDictionary dictionaryWithContentsOfURL:url];
justAnimalNames = animalDetails.allKeys;
// Do any additional setup after loading the view, typically from a nib. }
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return animalDetails.count; }
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableView *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = justAnimalNames [indexPath.row];
return cell; }
我得到的错误是在这一行:
cell.textLabel.text = justAnimalNames [indexPath.row];
在“ UITableview”类型的对象上找不到属性“ textLabel”
有任何想法吗 ?
您的cell
必须是UITableViewCell *
而不是UITableView *
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.