繁体   English   中英

数组不显示值

[英]An array don't show the values

你好!

我尝试从数组中提取值( prepTime ),但它不会显示它们。 当我编译程序时,我收到一个错误:

0xec80b0:  cmpl   (%eax), %ecx        Thread 1: EXC_BAD_ACCESS (code=1, address=0xff31e10)

在这里我创建了数组:

{
    NSArray *tableData;
    NSArray *thumbnails;
    NSArray *prepTime;    //Here I created the array
}

在这里,我填充了价值观:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Initialize table data
    tableData = [NSArray arrayWithObjects:@"Egg Benedict", ... @"Angry Birds Cake", @"Ham and Cheese Panini", nil];

    // Initialize thumbnails
    thumbnails = [NSArray arrayWithObjects:@"egg_benedict.jpg", ... @"angry_birds_cake.jpg", @"ham_and_cheese_panini.jpg", nil];

    //Initialize prep time
    prepTime=[NSArray arrayWithObjects: @"90 min", "60 min", "45 min", ... "10 min", "60 min", "40 min",   nil];
}

正如您所看到的,我的代码中有三个数组被定义并填充了值,但只有' prepTime '数组不会在我的表单元格中显示它的值,而是在编译它时给出错误。

为什么会这样?

非常感谢!

看起来你错过了一些字符串文字中的@符号:

prepTime=[NSArray arrayWithObjects: @"90 min", "60 min", "45 min", ... "10 min", "60 min", "40 min",   nil];
//                                             ^Here     ^Here         ^Here     ^Here     ^Here

尝试以NSString访问生成的C字符串会导致访问不良。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM