首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在合适的视图中加载数据

在合适的视图中加载数据
EN

Stack Overflow用户
提问于 2011-04-18 15:52:05
回答 1查看 304关注 0票数 0

我正在开发一个简单的基于视图的应用程序,其中包含两个按钮和一个解析rss feed.my视图的表视图在顶部有两个按钮,我从界面builder...ive添加uitableview,添加委托和表视图的数据源作为文件的owner....the解析过程在一个单独的文件中完成,我正在使用delgation来接收解析的data....every东西工作良好,除了self.tableView reloadData,它给出一个错误,如果我要评论这个,我没有得到要加载到表视图中的数据...如果im要创建基于导航的application.but,则解析数据的....this加载工作良好。如果我要创建基于视图的应用程序并从接口构建器编程添加表视图,则会产生问题,cud你们帮我out....below就是代码..

代码语言:javascript
复制
@implementation FirstViewController

@synthesize items;

@synthesize items2;

- (void)viewDidLoad
 {
    [super viewDidLoad];


    [self loadData];


}

-(void)loadData

{

if (items==nil) 
    {

Parser1 *rssparser=[[Parser1 alloc]init];   

rssparser.delegate=self;

[UIApplication sharedApplication].networkActivityIndicatorVisible=YES;

[activityIndicator startAnimating];

[rssparser startRssFeed:@"http://api.flickr.com/services/feeds/photos_public.gne"];


        [rssparser release];
    }else
    {
        //[self.tableView reloadData];
    }
}
-(void)receiveFeeds:(NSArray *)theItems
{   
[UIApplication sharedApplication].networkActivityIndicatorVisible=NO;

[activityIndicator stopAnimating];

items=theItems;

NSLog(@"ha ha ha items:%@",items);
    //[self.tableView reloadData];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {


    return [items count];

}
- (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];

 }

    cell.textLabel.text=[[items objectAtIndex:indexPath.row]objectForKey:@"title"];
    cell.textLabel.text=@"hello";

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

   return cell;
}
EN

Stack Overflow用户

回答已采纳

发布于 2011-04-18 16:27:32

尝试在环境设置中使用NSZombieEnabled = YES来运行你的应用。也许你在某处遇到了内存分配问题。

我有根据的猜测是: items=theItems;

您不保留items数组,它会在您使用它之前自动释放

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5699985

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档