0

I am trying to initialize two NSArrays with the following code

self.fillingTypes = [[NSArray alloc] initWithObjects:@"Ham",@"Turkey",@"Peanut Butter", @"Tuna Salad",@"Roast Beef",@"Vegemite", nil];

self.breadTypes = [[NSArray alloc] initWithObjects:@"White",@"Whole Wheat", @"Rye", "@Sourdough", @"Seven Grain", nil];`

The fillingTypes array works but the breadTypes array crashes sending a EXC_BAD_ACCESS error. When I step through it the breadTypes array says "Variable is not a CFArray". Why would one array work and the other fail?

Daniel
  • 22,363
  • 9
  • 64
  • 71
mimc
  • 111
  • 1
  • 7

1 Answers1

7

Problem is you "@Sourdough" in there instead of @"Sourdough" which like the comments say generates a warning and will crash the program..the line should read

self.breadTypes = [[NSArray alloc] initWithObjects:@"White",@"Whole Wheat", @"Rye", @"Sourdough", @"Seven Grain", nil];
Daniel
  • 22,363
  • 9
  • 64
  • 71