Ayrad
Ayrad

Reputation: 4056

CGFloat from a float?

How do you cast or create a CGFloat from a float?

I get a bad receiver type float * error.

CGFloat point = [graphValues objectAtIndex:0];

Upvotes: 1

Views: 3094

Answers (2)

user187676
user187676

Reputation:

That's because the array is not an NSArray but a float array.

CGFloat point = graphValues[0];

If you want to know how CGFloat is declared, have a look in the header (it should be a double).

Upvotes: 2

Wevah
Wevah

Reputation: 28242

graphValues is probably not an NSArray, but a C-array of floats. If so, you want this:

CGFloat point = graphValues[0];

(The reason I think this is because it's telling you you're trying to call an Objective-C method on a float *.)

Upvotes: 3

Related Questions