If I'm correct, Objective-C's int
type length depends on the platform word length (i.e. it's 64 bit when running in a 64-bit environment and 32-bit when running in a 32-bit environment).
However, when bridging an Objective-C interface to Swift, this type is bridged as Int32
which explicitly defines the size of 32 bits.
Is this an error, or int
in Objective-C always occupies 32 bit? If it's not an error, why it gets bridged as Int32
?
Example of the Objective-C interface
-(int)numberOfItems;
Which gets bridged into:
func numberOfItems -> Int32
When I change the method signature to use NSInteger
, it get's bridged correctly:
-(NSInteger)numberOfItems;
func numberOfItems -> Int
Is there any danger if I change int
in Objective-C to NSInteger
, or these types behave in exactly the same manner in Objective-C?