UITableView 无法从数组中获取数据

发布于 2024-12-24 16:53:40 字数 697 浏览 0 评论 0原文

我正在制作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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星軌x 2024-12-31 16:53:40

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文