Andrew
Andrew

Reputation: 16051

Getting a 'Assignment makes integer from pointer without cast' error

And i can't seem to figure it out. Here's one of the lines it has trouble with:

hourToReadOut = currentHourInt - 12;

hoursToReadOut and currentHoursInt are both integers from the .h file. currentHourInt is always set to something.

Upvotes: 0

Views: 305

Answers (2)

Nick Curran
Nick Curran

Reputation: 484

Did you maybe declare one as a pointer to an int? NSInteger* when you meant NSInteger or int* instead of int? Or is one perhaps an NSNumber object from which you should be calling intValue?

Upvotes: 1

peoro
peoro

Reputation: 26060

This error is given when you assign a pointer to an integer:

int *intPtr;
int intVar;
intVar = intPtr - 12;

It looks like currentHourInt is a pointer, not an integer, are you really sure it's not?

Upvotes: 5

Related Questions