UITableView 无法从数组中获取数据
我正在制作iPad应用程序,其中我从Url获取数据,从URL获取数据后,
我存储到数组中,
当我在这两个TableView方法中写入NSLOG时,
它工作正常,
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLOG(@"ARRAY=%@",arrayname);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLOG(@"ARRAY=%@",arrayname);
}
但是当我在这个方法中写入这个NSLOG时然后它显示错误,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLOG(@"ARRAY=%@",arrayname);
}
我还正确声明了 nsmutablearray....
它显示 EXC_BAD_ACCESS
为什么有这个想法?
i am making iPad application, in which i am fetching data from Url, after fetching data from URL,
i am storing into array,
when i write NSLOG inside this two TableView method,
it works properly,
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLOG(@"ARRAY=%@",arrayname);
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLOG(@"ARRAY=%@",arrayname);
}
but when i write this NSLOG inside this method thn it shows error,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSLOG(@"ARRAY=%@",arrayname);
}
i also declared nsmutablearray properly....
it shows EXC_BAD_ACCESS
why this any idea ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cellForRowAtIndexPath 方法必须返回单元格,否则您将看到所看到的错误。但是,如果上面的代码是“元代码”,并且您将 NSLog 放在正确的代码字符串之间,那么您可以遵循 Alex Reynolds 的建议。
检查您的阵列是否仍然存在。例如,您可以设置一个断点并检查程序是否由于转向“arrayname”而失败,如果是,请尝试找到此时可以在代码中释放它的位置。另外,也许您只是错误地创建了数组。
The method cellForRowAtIndexPath must return the cell, otherwise you'll see the error you see. But if the code above is 'metacode', and you put you NSLog somwhere between the proper strings of code, then you can follow Alex Reynolds' advice.
Check if your array is still alive. E.g. you can set a breakpoint and check if the program falls because of turning to 'arrayname', and if so, try to find where it could be released in your code by this moment. Also, perhaps you're just create your array with wrongly.