开发者

Can't find self.tableview after accidental delete

开发者 https://www.devze.com 2023-02-28 21:08 出处:网络
I accidentally deleted my firstviewcontroller.m file which is for a view that has a tableview. I then re-created my .m file the best I can remember and thought I had it all correct.

I accidentally deleted my firstviewcontroller.m file which is for a view that has a tableview. I then re-created my .m file the best I can remember and thought I had it all correct.

I'm now getting an error on the line

[self.tableview refresh];

saying self.tableview isn't found.

I can't seem to figure out what I missed. I don't want to overwhelm you guys with code so I'll try to just post the pertinent part.

#import "FirstViewController.h"

#import "Shared.h"

#import "Message.h"

@implementation FirstViewController

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

Message *msg = [[Shared sharedInstance].messages objectAtIndex:indexPath.row];

NSString *authorName = msg.authorName;

NSString *cellValue = authorName;

cell.textL开发者_运维百科abel.text = cellValue;

return cell;

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

`return [[Shared sharedInstance].messages count];`  

}

-(void) viewWillAppear:(BOOL)animated {

`[self.tableView reloadData];`  

}


tableView is a property of UITableViewController. Double-check that you inherited FirstViewController from a UITableViewController, but not from UIViewController.

0

精彩评论

暂无评论...
验证码 换一张
取 消