title: Benefits of using NSInteger over int?
body: <p>I am trying to comprehend how development is affected when developing for both 32-bit and 64-bit architectures. From what I have researched thus far, I understand an <code>int</code> is always 4 bytes regardless of the architecture of the device running the app. But an <code>NSInteger</code> is 4 bytes on a 32-bit device and 8 bytes on a 64-bit device. I get the impression <code>NSInteger</code> is "safer" and recommended but I'm not sure what the reasoning is for that.</p>
  
  <p>My question is, if you know the possible value you're using is never going to be large (maybe you're using it to index into an array of 200 items or store the count of objects in an array), why define it as an <code>NSInteger</code>? That's just going to take up 8 bytes when you won't use it all. Is it better to define it as an <code>int</code> in those cases? If so, in what case would you want to use an <code>NSInteger</code> (as opposed to <code>int</code> or <code>long</code> etc)? Obviously if you needed to utilize larger numbers, you could with the 64-bit architecture. But if you needed it to also work on 32-bit devices, would you not use <code>long long</code> because it's 8 bytes on 32-bit devices as well? I don't see why one would use <code>NSInteger</code>, at least when creating an app that runs on both architectures.</p>
  
  <p>Also I cannot think of a method which takes in or returns a primitive type - <code>int</code>, and instead utilizes <code>NSInteger</code>, and am wondering if there is more to it than just the size of the values. For example, <code>(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section</code>. I'd like to understand why this is the case. Assuming it's possible to have a table with 2,147,483,647 rows, what would occur on a 32-bit device when you add one more - does it wrap around to a -2,147,483,647? And on a 64-bit device it would be 2,147,483,648. (Why return a signed value? I'd think it should be unsigned since you can't have a negative number of rows.)</p>
  
  <p>Ultimately, I'd like to obtain a better understanding of actual use of these number data types, perhaps some code examples would be great!</p>