Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert CFIndex to NSUInteger?

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?

like image 972
ma11hew28 Avatar asked Aug 01 '26 16:08

ma11hew28


1 Answers

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.

like image 114
Rob Napier Avatar answered Aug 03 '26 19:08

Rob Napier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!