OHPDFImage icon indicating copy to clipboard operation
OHPDFImage copied to clipboard

Why size_t ?

Open colasbd opened this issue 10 years ago • 1 comments

I don't understand why you chose to use size_t in your framework and not more common type, such as NSUInteger.

Maybe the number of bytes is not the same?

Anyway, isn't it a bad choice? Indeed, your library is de facto a wrapper for CFPDFDocumentRef and should, IMHO, use common types.

For instance, when I see size_t, I don't understand. NSUInteger is much more Objective-C-friendly.

colasbd avatar Apr 28 '15 13:04 colasbd

size_t is the official type for sizes in the CoreFoundation world.

as methods like CGPDFDocumentGetNumberOfPages actually has a return type of size_t, that's why I exposed the same type in the pagesCount property, to ensure not to do any casting that could have lost some integer precision (underflow, etc).

But as OHPDFImage is intended to be a wrapper after all, that would make sense to make that cast to expose an NSUInteger instead. We just have to ensure this conversion is not lossy.

AliSoftware avatar Apr 28 '15 18:04 AliSoftware