iOS - EXC 访问错误,以前在 iOS 4 上工作过

发布于 2024-12-14 04:17:35 字数 354 浏览 4 评论 0原文

除非我疯了,否则这在 iOS4 上可以正常工作。我更新到 iOS5,现在它在 [indexPath 部分] 上抛出此错误访问错误。它位于 UITableView 上:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    // Get the cell label and value
    NSLog(@"section: %@", [indexPath section]); /* BAD ACCESS ERROR HERE */
...

Unless I'm out of my mind, this was working properly on iOS4. I updated to iOS5, and now it's throwing this bad access error on [indexPath section]. It's on a UITableView:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    // Get the cell label and value
    NSLog(@"section: %@", [indexPath section]); /* BAD ACCESS ERROR HERE */
...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

幻梦 2024-12-21 04:17:35

日志语句本身导致了错误。

NSLog(@"section: %@", [indexPath section]); /* BAD ACCESS ERROR HERE */

您正在尝试记录一个整数,就好像它是一个对象一样。应该是:

NSLog(@"section: %i", [indexPath section]);

The log statement itself is causing the error.

NSLog(@"section: %@", [indexPath section]); /* BAD ACCESS ERROR HERE */

You are trying to log an integer as if it was an object. It should be:

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