Three20 我的数据未显示在我的TTTableViewController子类中。为什么不呢?

Three20 我的数据未显示在我的TTTableViewController子类中。为什么不呢?,three20,Three20,以下是背景:我正在初始化并设置我的TTTableViewController中的数据源,如下所示: - (void)createModel { TTSectionedDataSource *dataSource = [[[TTSectionedDataSource alloc] init] autorelease]; dataSource.model = [[[LogsModel alloc] init] autorelease]; self.dataSource = d

以下是背景:我正在初始化并设置我的
TTTableViewController
中的数据源,如下所示:

- (void)createModel {
    TTSectionedDataSource *dataSource = [[[TTSectionedDataSource alloc] init] autorelease];
    dataSource.model = [[[LogsModel alloc] init] autorelease];
    self.dataSource = dataSource;
}
- (void)modelDidFinishLoad:(id<TTModel>)model {
    ((TTSectionedDataSource *)self.dataSource).items = ((LogsModel *)model).items;
    ((TTSectionedDataSource *)self.dataSource).sections = ((LogsModel *)model).sections;
    [super modelDidFinishLoad:model];
}
该模型是一个
TTURLRequestModel
,因此当从该模型返回响应时,我在
TTTableViewController
中设置数据源的项和节,如下所示:

- (void)createModel {
    TTSectionedDataSource *dataSource = [[[TTSectionedDataSource alloc] init] autorelease];
    dataSource.model = [[[LogsModel alloc] init] autorelease];
    self.dataSource = dataSource;
}
- (void)modelDidFinishLoad:(id<TTModel>)model {
    ((TTSectionedDataSource *)self.dataSource).items = ((LogsModel *)model).items;
    ((TTSectionedDataSource *)self.dataSource).sections = ((LogsModel *)model).sections;
    [super modelDidFinishLoad:model];
}
-(void)modeldiffinishload:(id)model{
((TTSectionedDataSource*)self.dataSource.items=((LogsModel*)model.items;
((TTSectionedDataSource*)self.dataSource).sections=((LogsModel*)model.sections;
[super modeldiffinishload:model];
}

当我从在模型中使用硬编码数据切换到实际向web服务发出请求时,出现了这个问题。我做错了什么?我是否创建的模型不正确?或者将数据源上的项和节设置在错误的位置?欢迎提出任何想法或意见。谢谢

终于找到了原因。在我的模型类(上面代码的LogsModel)中,当我使用硬编码数据时,我实现了
-(BOOL)isLoaded
方法。当我切换到向web服务发出请求时,我的
isLoaded
实现始终返回NO,因此TTTableViewController没有显示我的数据。我删除了我的
-(BOOL)isLoaded的实现,问题就解决了。

我建议大家看看three20的twitter演示应用程序(TTTwitter)。Three20提供了一种分离模型/数据源和表的简化方法

控制器应仅创建数据源,而不“知道”项目和部分:

///////////////////////////////////////////////////////////////////////////////////////////////////
 - (void)createModel {
 self.dataSource = [[[TTTwitterSearchFeedDataSource alloc]
                  initWithSearchQuery:@"three20"] autorelease];
}

你能展示一下你是如何实现isLoaded方法的吗?因为我认为我的问题与此类似。@bac也是Vincent-我更新了我的答案。解决方案是删除
-(BOOL)isLoaded
的任何自定义实现。