【问题标题】:Expected Identifier cell.textLabel.text = @"Facebook" error [closed]预期标识符 cell.textLabel.text = @"Facebook" 错误 [关闭]
【发布时间】:2013-12-14 22:27:27
【问题描述】:

我在 xCode 5.0.2 工作,我是新手,所以请原谅我问了这么一个基本问题...

我收到带有以下编码的“预期标识符”错误:

UITableViewCell *Cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
[Cell.textLabel.text = @"Facebook"];
[O_TableArray addObject:Cell];
[Cell release];
Cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
[Cell.textLabel.text = @"Twitter"];
[O_TableArray addObject:Cell];
[Cell release];
Cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
[Cell.textLabel.text = @"Tumblr"];
[O_TableArray addObject:Cell];
[Cell release];
Cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
[Cell.textLabel.text = @"Email"];
[O_TableArray addObject:Cell];
[Cell release];

我不确定我做错了什么,但如果你能提供任何建议,我将不胜感激。

提前感谢您的时间和考虑!

【问题讨论】:

  • 为什么要创建这么多单元格?以下是接下来几个月的任务: 1) 学习 Objective-C,不要只是复制随机代码而不试图理解它们。 2) 学习如何填充 UITableViews 3) 遵守编码约定
  • 我不同意每个人都反对并投票结束这个问题。是的,这是一个新手错误,OP 显然应该完成一个教程或课程 - 但这是一个格式正确的具体问题,包括错误消息和不正确的代码。

标签: objective-c


【解决方案1】:

改变

[Cell.textLabel.text = @"Facebook"];

Cell.textLabel.text = @"Facebook";

[Cell.textLabel setText:@"Facebook"];

[[Cell textLabel] setText:@"Facebook"];

(您错误地组合了点和括号表示法。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-06
    • 2013-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多