带有解析错误帮助的UITableView“NSInternalInconsistencyException”

时间:2014-08-08 20:18:16

标签: objective-c uitableview debugging

我似乎无法找到我的错误,任何人都可以帮助我吗?当我尝试运行测试应用程序时它一直工作,直到我点击日历按钮,它是表视图页面的segue,它只是冻结并在调试器中出现此错误。

  

014-08-08 15:54:57.533 nths [2171:607] **断言失败    - [UITableView _configureCellForDisplay:forIndexPath:],/ SourceCache / UIKit_Sim / UIKit-2935.137 / UITableView.m:6509

     

2014-08-08 15:54:57.536 nths [2171:607] **由于终止应用程序   未被捕获的异常' NSInternalInconsistencyException',原因:   ' UITableView dataSource必须从中返回一个单元格   的tableView:的cellForRowAtIndexPath:'    * 第一次抛出调用堆栈:

以下是我认为会对此产生影响的所有代码。

CalendarViewController.h

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
#import "DataCellViewController.h"

@interface CalendarViewController : UIViewController <UITableViewDelegate> {
    NSArray *eventArray;
}

@property (weak, nonatomic)IBOutlet UITableView *Datatable;

@end

CalendarViewController.m

#import "CalendarViewController.h"

@interface CalendarViewController ( )

@end

@implementation CalendarViewController

@synthesize Datatable;

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

    [self performSelector:@selector(retrieveFromParse)];
}

- (void) retrieveFromParse {

    PFQuery *retrieveDate = [PFQuery queryWithClassName:@"Calendar"];

    [retrieveDate findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
           NSLog(@"%@",objects);
    if (!error) {
            eventArray = [[NSArray alloc] initWithArray:objects];
        }
        [Datatable reloadData];
    }];
}

//Setup table of folder names

//get number of sections in tableview
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

//get number of rows by counting number of folders
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return eventArray.count;
}

//setup cells in tableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath         *)indexPath {

    //setup cell
    static NSString *CellIdentifier = @"CalenderCell";
    DataCellViewController *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    NSDictionary *tempDict = [eventArray objectAtIndex:indexPath.row];

    cell.eventTitle.text = [tempDict objectForKey:@"eventTitle"];

    NSLog(@"array contents: %@", eventArray);

    return cell;
}

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

@end

DataCellViewController.h

#import <UIKit/UIKit.h>

@interface DataCellViewController : UITableViewCell

@property (nonatomic, strong)IBOutlet UILabel *eventTitle;

@end

DataCellViewController.m

#import "DataCellViewController.h"

@interface DataCellViewController ( )

@end

@implementation DataCellViewController

@synthesize eventTitle;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       // Initialization code
     }
    return self;
 }

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end

0 个答案:

没有答案