简体   繁体   中英

An array don't show the values

Hello!

I try to extract the values from an array ( prepTime ), but it don't show them. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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