Objective c 发送到实例的典型UITableView无法识别的选择器

Objective c 发送到实例的典型UITableView无法识别的选择器,objective-c,ios,selector,Objective C,Ios,Selector,我遇到了这样一个“tableView:CellForRowatineXpath::无法识别的选择器发送到实例”错误,我几乎可以肯定这是某种内存管理问题,但现在我已经厌倦了查找错误。 如果不向下滚动,则TableView可以很好地显示单元格。。 应用程序崩溃。 我使用的唯一属性是“地点”,我已经检查过是否遗漏了“自我” 所以。。这是我的密码: #import "PlacesViewController.h" #import "FlickrFetcher.h" #import "SinglePlac

我遇到了这样一个“tableView:CellForRowatineXpath::无法识别的选择器发送到实例”错误,我几乎可以肯定这是某种内存管理问题,但现在我已经厌倦了查找错误。 如果不向下滚动,则TableView可以很好地显示单元格。。 应用程序崩溃。 我使用的唯一属性是“地点”,我已经检查过是否遗漏了“自我”

所以。。这是我的密码:

#import "PlacesViewController.h"
#import "FlickrFetcher.h"
#import "SinglePlaceViewController.h"

@implementation PlacesViewController

@synthesize places;

- (NSArray *)places
{
    if (!places) {
        NSSortDescriptor *content = [[NSSortDescriptor alloc] initWithKey:@"_content" ascending:YES];
        NSArray *unsortedPlaces = [FlickrFetcher topPlaces];    
        places = [unsortedPlaces sortedArrayUsingDescriptors:[NSArray arrayWithObjects: content, nil]];
    }
    return places;
}

#pragma mark -
#pragma mark Initialization

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Top Places";
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return YES;
}


#pragma mark -
#pragma mark Table view data source

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


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return self.places.count;
}

- (NSDictionary *)placeAtIndexPath:(NSIndexPath *)indexPath
{
    return [self.places objectAtIndex:indexPath.row];
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"PlacesTableViewCell";
    NSLog(@"%@", [FlickrFetcher topPlaces]);
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    NSString *location = [[self placeAtIndexPath:indexPath] objectForKey:@"_content"];
    NSArray *splitLocation = [location componentsSeparatedByString:@", "];
    cell.textLabel.text = [splitLocation objectAtIndex:0];
    if (splitLocation.count == 2)
        cell.detailTextLabel.text = [splitLocation objectAtIndex:1];
    if (splitLocation.count == 3)
        cell.detailTextLabel.text = [[[splitLocation objectAtIndex:1] stringByAppendingString:@","] stringByAppendingString:[splitLocation objectAtIndex:2]];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Navigation logic may go here. Create and push another view controller.

    SinglePlaceViewController *spvc = [[SinglePlaceViewController alloc] init];
    // Pass the selected object to the new view controller.
    spvc.placeId = [[self placeAtIndexPath:indexPath] objectForKey:@"place_id"];
    [self.navigationController pushViewController:spvc animated:YES];
    [spvc release];

}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    // For example: self.myOutlet = nil;
}


- (void)dealloc {
    [places release];
    [super dealloc];
}


@end

非常感谢您的帮助,我真的很抱歉让大家为我做了一些工作。

您没有提供有关错误的详细信息,因此我只能猜测:

该错误表示获取消息
cellforrowatinexpath:
的对象实际上没有实现此方法。 但既然您实现了它,我能想到的唯一原因就是您弄乱了tableView的“dataSource”属性,并将其更改为不应该更改的内容


确保数据源是您的
PlacecViewController

从我看来,您的
places
属性的getter方法不保留它返回的值。您正在将其设置为从
sortedArray
方法获得的
NSArray
的自动删除实例。我敢打赌,它会在显示您的初始tableview单元格后发布。

您能否省略整个
//配置单元格…
部分并滚动?我知道这不会显示文本,但它会崩溃吗?请发布stacktrace和完整的控制台输出。
PlacesViewController
继承了哪个类?您应该查看TableView的委托您是否尝试在项目中设置异常断点?消息发送到哪里?谁是接线员?