错误 - (void)reloadData [关闭]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误 - (void)reloadData [关闭]相关的知识,希望对你有一定的参考价值。

您好我正在使用HERE的本教程创建一个SQLite数据库并在表视图上查看它。现在我在我的应用程序上面临一个错误,我不知道调试它。如果有人可以帮我解决这个错误,请做!

非常感谢你!!!

这是我当前的ViewController.m的代码我试过运行僵尸模式,但它没有帮助调试我目前面临的错误...

import "ViewController.h"

import "DBManager.h"

@interface ViewController ()

@property (nonatomic, strong) DBManager *dbManager;

@property (nonatomic, strong) NSArray *arrPeopleInfo;

-(void)loadData;

@end

@implementation ViewController

- (void)viewDidLoad 
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    // Make self the delegate and datasource of the table view.
    self.tblPeople.delegate = self;
    self.tblPeople.dataSource = self;


-(void)editingInfoWasFinished
    // Reload the data.
    [self loadData];


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    EditInfoViewController *editInfoViewController = [segue destinationViewController];
    editInfoViewController.delegate = self;


-(void)loadData
    // Form the query.
    NSString *query = @"select * from peopleInfo";

    // Get the results.
    if (self.arrPeopleInfo != nil) 
        self.arrPeopleInfo = nil;
    
    self.arrPeopleInfo = [[NSArray alloc] initWithArray:[self.dbManager loadDataFromDB:query]];

    // Reload the table view.
    [self.tblPeople reloadData];

    // Load the data.
    [self loadData];


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    return 1;



-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    return self.arrPeopleInfo.count;



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    return 60.0;


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    // Dequeue the cell.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"idCellRecord" forIndexPath:indexPath];

    NSInteger indexOfFirstname = [self.dbManager.arrColumnNames indexOfObject:@"firstname"];
    NSInteger indexOfLastname = [self.dbManager.arrColumnNames indexOfObject:@"lastname"];
    NSInteger indexOfAge = [self.dbManager.arrColumnNames indexOfObject:@"age"];

    // Set the loaded data to the appropriate cell labels.
    cell.textLabel.text = [NSString stringWithFormat:@"%@ %@", [[self.arrPeopleInfo objectAtIndex:indexPath.row] objectAtIndex:indexOfFirstname], [[self.arrPeopleInfo objectAtIndex:indexPath.row] objectAtIndex:indexOfLastname]];

    cell.detailTextLabel.text = [NSString stringWithFormat:@"Age: %@", [[self.arrPeopleInfo objectAtIndex:indexPath.row] objectAtIndex:indexOfAge]];

    return cell;


- (void)didReceiveMemoryWarning 
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.



- (IBAction)addNewRecord:(id)sender 
    [self performSegueWithIdentifier:@"idSegueEditInfo" sender:self];

@end
答案

问题是你递归调用相同的方法

-(void)loadData

   // Reload the table view.
     [self.tblPeople reloadData];

   // Load the data.
    [self loadData]; // should comment this

以上是关于错误 - (void)reloadData [关闭]的主要内容,如果未能解决你的问题,请参考以下文章

为啥UITableView不能reloadData

UIImagePickerController 关闭后 UICollectionView 不会 reloadData()

UITableViewCell 在 reloadData 后变为 nil

错误:从 'void*' 到 'node_t*' 的无效转换 [关闭]

reloadData 不适用于 iOS7 中的 UICollectionView

UITableView.reloadData() 没有刷新 tableView。没有错误信息