3

How do I convert typedef signed long CFIndex to typedef unsigned int NSUInteger?

Is it OK if I use a CFIndex as an argument of type NSUInteger. I haven't casted it, and the complier doesn't seem to mind. Does the compiler just do the conversion for me?

ma11hew28
  • 121,420
  • 116
  • 450
  • 651

2 Answers2

5

You need to be very careful here, since CFIndex is signed and NSUInteger is unsigned. There are various routines that return a CFIndex -1. You need to check for that before using it as an NSUInteger.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
-1

Yes, the compiler performs implicit type conversion.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651