On 26 Mar 2014, at 17:05, Chris Hanson <c...@me.com> wrote:

> On Mar 25, 2014, at 4:55 PM, Jens Alfke <j...@mooseyard.com> wrote:
> 
>> So if something is supposed to be a particular size (as seems to happen in 
>> your app) declare it as a type of that size. If you don’t care about the 
>> size and it won’t ever exceed a few billion, use `int` or `unsigned`. If it 
>> needs to hold huge values, or if you want to be really conservative, use 
>> `SInt64` or `UInt64`.
> 
> You should generally prefer NSInteger and NSUInteger if you're writing code 
> to fit Cocoa patterns and the <stdint.h> types (uint32_t etc.) if you're 
> writing code that needs exact-width or minimum-width integers (the header has 
> both).
> 
> I'd avoid legacy Carbon types like "SInt32" in new code; compatibility needs 
> may require them to be defined in different ways than you expect.

Yeah, well I want to be able to fit into the Cocoa Patterns, that’s why I posed 
the question in the first place…….

This leads me to another question, if I am doing a lot of arithmetic on these 
numbers, what is the best type/fastest, native or NSInteger?

I’ve defined my own set of file types, based on int32_t and friends and have 
made each property definition follow this type. If it’s noticible faster using 
NSInteger for arithmetic, then I was planning of moving the native type 
properties to iVar’s and making the Properties NSInteger's, I’d then write 
getters to return the value as an NSInteger rather than the native type.

Cheers
Dave


_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to