Casting int to float

Submitted by:Pitter Alderson

Date added:23 September, 2013

Category:C

Method to convert int to float in ObjC

Tags: convert float

Code Snippet:

// First objective c style

int b = 10;
float a = [[NSNumber numberWithInt: b] floatValue]
There will be NSNumber instance and messages numberWithInt, floatValue will be send, right?

// Second c style

int b = 10;
float a = (float) b;
 
 

Comments