iphone - objective c arrays of floats and booleans possible? -


nsarray chemconstantarray = [[nsarray alloc] initwithobjects:0.0021400, 0.0012840, 0.0010700, nil]; 

gives me 4 errors:

incompatible type argument 1 of 'initwithobjects:'

invalid initializer

statically allocated instance of objective-c class 'nsarray' x 2

which makes sense, floats not objects, how can make array of floats. need 1 bools too.

if need array purely within own code, can use regular c array:

float chemconstantarray[] = {0.0021400, 0.0012840, 0.0010700}; 

if need nsarray* something, need wrap each value nsnumber.

nsarray *chemconstantarray = [[nsarray alloc] initwithobjects:     [nsnumber numberwithfloat: 0.0021400],     [nsnumber numberwithfloat: 0.0012840],     [nsnumber numberwithfloat: 0.0010700],     nil]; 

you can use numberwithbool bools.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -