简体   繁体   English

无法将内容从plist获取到UITableview

[英]Can't get content from plist to UITableview

Hello i am getting this error and i can't find where is the problem 您好,我收到此错误,但我找不到问题所在

my code is this : 我的代码是这样的:

@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; }

And the error i am getting is in this line : 我得到的错误是在这一行:

cell.textLabel.text = justAnimalNames [indexPath.row];

property 'textLabel' not found on object of type 'UITableview' 在“ UITableview”类型的对象上找不到属性“ textLabel”

any ideas ? 有任何想法吗 ?

您的cell必须是UITableViewCell *而不是UITableView *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM