Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShaun Kelly
5,648 PointsType Casting!?
Can somebody please explain what type casting is?
ProjectileNode *projectile = (ProjectileNode*) firstBody.node;
//^^^
2 Answers
Shaun Kelly
5,648 PointsIs that Objective-C
Russell Warwick
1,601 PointsSorry my bad, there you go ;)
Russell Warwick
1,601 PointsDo you understand it?
Shaun Kelly
5,648 Pointsnot really haha because isn't the float already an int ? or I must be getting mixed up with something else
Russell Warwick
1,601 PointsRussell Warwick
1,601 PointsOkay so im not an expert by any means but basically it is away of changing the type of something for your example because ProjectileNode is of type SKSpriteNode but you assigning it to an SKNode so it just allows you to change it.<p></p> Here is an example using the value of a integer for the value of a float. <p>``` int x=6;
float y =(int)x;
NSLog(@"Float y:%f",y); </p>