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
Post a Comment