I have a subclass of uiview and in it's initWithFrame:
method I'm converting a nsarray to a float array like so:
NSArray *numbersArray = @[[NSNumber numberWithFloat:0.2], [NSNumber numberWithFloat:.8], [NSNumber numberWithFloat:.3], [NSNumber numberWithFloat:.6], [NSNumber numberWithFloat:.2]];
data = malloc(numbersArray.count * sizeof(float));
if (data == NULL) {
// handle error
}
[numbersArray enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(NSNumber *number, NSUInteger idx, BOOL *stop) {
data[idx] = [number floatValue];
}];
//free(floatsArray);
for (int i = 0; i < sizeof (data) / sizeof (float); i++) {
NSLog(@"float value found at %i => %f", i, data[i]);
}
If you run the code yourself, you'll see that it only returns 2 values from the array. What am I doing wrong here?