tags:

views:

1646

answers:

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?

A: 

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.

peterb
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