简体   繁体   English

数组不显示值

[英]An array don't show the values

Hello! 你好!

I try to extract the values from an array ( prepTime ), but it don't show them. 我尝试从数组中提取值( prepTime ),但它不会显示它们。 When I compile the program I get an error: 当我编译程序时,我收到一个错误:

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

Here I created the array: 在这里我创建了数组:

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

Here I filled it with values: 在这里,我填充了价值观:

- (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];
}

As you can see there are three arrays in my code were defined and filled with values, but only ' prepTime ' array don't show it values in my table cell and give an error when compile it instead. 正如您所看到的,我的代码中有三个数组被定义并填充了值,但只有' prepTime '数组不会在我的表单元格中显示它的值,而是在编译它时给出错误。

Why it happens? 为什么会这样?

Thanks a lot! 非常感谢!

It looks like you have missed a few @ signs in some of your string literals: 看起来你错过了一些字符串文字中的@符号:

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

Trying to access the resultant C strings as NSString causes bad access. 尝试以NSString访问生成的C字符串会导致访问不良。

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

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