Is it wrong to use int in Cocoa and CocoaTouch?

What is the advantage of using code NSIntegerinstead of intin code? I see this in the examples a lot, including samples of the official Apple code.

+3
source share
3 answers

There is a similar question here at SO.com: In Cocoa, do you prefer NSInteger or int, and why? I prefer to use NSIntegerit because it's the future, Apple is now using it on top int, and this is the recommended way to do things.

But this is not "wrong" to use int.

+3
source

, NSInteger NSUInteger 64- Mac OS ( , ). , , iPhone, Apple NS -types.

, - Mac OS, .

+3
  • 32- ( iPhone): int - 4 , long - 4 , - 4
  • 64- : int - 4 , long - 8 , - 8

API (, ) int 32- , long 64- .

C, int long , , int, 64- API, long, 32 - API. NSInteger, 32- 64- API.

, API, NSInteger, NSInteger.

API-:

  • 4- , int
  • , long NSInteger
  • 8- , long long

, NSInteger , , 8- .

+2
source

Source: https://habr.com/ru/post/1724347/


All Articles