Saturday, July 21, 2012

convert NSArray in float[]


        NSArray *c=[NSArray arrayWithObjects:@"1",@"8",@"4",@"2",nil];
        
        NSEnumerator *enumerator;
        float * cArray;
        id obj;
        int index=0;
        
        cArray = (float *) malloc(sizeof(float) * [c count]);
        enumerator = [c objectEnumerator];
        while(obj = [enumerator nextObject])
        {
            cArray[index] = [obj floatValue];
            index++;
        }
        



       


1 comment:

  1. Obviously, this is still a slooooooow thing to do, so take after ThemsAllTook's recommendation and don't utilize a NSArray for this if conceivable. What I'd do, by and by, is given NSArray a chance to deal with your capacity while you're building or generally controlling your information. Be that as it may, once your information's prepared, duplicate it over to a crude exhibit and let go of the NSArray. Visit website.

    ReplyDelete