Tag Archives: 64bit

How to covert an NSUInteger / NSInteger into an int value

Before the addition of 64bit in iOS it was possible to take an NSUInteger (or NSInteger) and put it into an int variable, like so:

If you add 64bit support to your app you may notice a compiler warning when you do this:

This content is for members only.

Xcode understands that this is intentional and drops the warning.

How to check if your app is running in 64bit

There are two ways to determine this: at runtime (i.e. in your running code), and at compile time (i.e. before the code is compiled). Let’s take a look at both options.

Runtime Check

Determines the size of a pointer.

Compile Time Check

Asks the compiler which architecture it compiles for.

How to add 64bit support to your iOS apps

Apple’s new A7 processors support 64bit under iOS 7 – but only if your app is specifically compiled for 64bit. Ideally you want to compile once and use 64bit if the architecture supports it, and use 32bit for devices that have A4 – A6x processors and hence do not support 64bit.

Since Xcode 5.0.2 you can do this, and here’s how:

  • head over to your app’s target and choose Build Settings
  • under Architectures, choose “Standard architectures, including 64bit”
  • Xcode will offer to “Change the deployment target to iOS 5.1.1”
  • agree to it and you’re done

Now your app will choose the 64bit frameworks where available, and otherwise use 32bit.

Screen Shot 2013-11-16 at 12.29.24