On Dec 12, 2010, at 4:34 PM, Matt Neuburg wrote:

> I feel like I'm missing something. I can't seem to typecast as CFRange to an 
> NSRange.

Both are distinct C structs. In C, *explicitly* typecasting one pointer to the 
other would be allowed but semantically incorrect. In C++ casting a pointer to 
the other would be illegal.

> I know I can pull a CFRange apart and reassemble it as an NSRange, but 
> shouldn't there be a simpler way? m.

In fact, initializing a NSRange value from a CFRange value by means of a 
library function would not be as easy as it might look at the first glance. The 
reason is, CFRange has field members whose type is a *signed* long, and  
NSRange field types are *unsigned* ints or *unsigned* longs (the size depending 
on architecture). Mixing signed and unsigned types - possibly with different 
bit-sizes - in a simple assignment operation would require overflow checks and 
may require to throw exceptions. So, what should a library function do?

If required, you can include these checks in your code, though.


Regards
Andreas

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to