1

I've created a new class and i want to declare a NSDictionary containing a table of values so that it's available in the rest of my application.

I did it this way as a property of the class (modified):

NSDictionary *ell = [NSDictionary dictionaryWithObjectsAndKeys:
    [[JFEllipsoid alloc] initWithRadius:6377563.396 withInvF:299.3249646], @"key1",                         
    [[JFEllipsoid alloc] initWithRadius:6377340.189 withInvF:299.3249646], @"key2",
nil};

When i compile i get this error:

error: initializer element is not constant

How/Where can i declare this array of data so that it's available when i instance that class?

Jorge
  • 2,156
  • 2
  • 22
  • 29

1 Answers1

0

See this question:

To make a long story short, you can try declaring your string data as extern const before using them, or you can change the scope of where you're declaring your NSDictionary.

Community
  • 1
  • 1
peterb
  • 1,360
  • 9
  • 14
  • Sorry for simplyfing so much. The point is the objects in the Dictionary are not strings. They'd be something like this: NSDictionary *ell = [NSDictionary dictionaryWithObjectsAndKeys: [[JFEllipsoid alloc] initWithRadius:6377563.396 withInvF:299.3249646], @"key1", [[JFEllipsoid alloc] initWithRadius:6377340.189 withInvF:299.3249646], @"key2", nil}; – Jorge Aug 22 '09 at 16:15