DreamLab – Solve cancer while you sleep

Recommended By

Now more than ever, we have the power to change humanity with technology, and today we are helping cure cancer. Over the last 5 years cancer has taken away many people close to me, and

b2cloud are a BRW Fast 100 winner

Recommended By

It’s honouring to receive recognition for b2cloud as one of the 100 fastest growing companies in Australia in the BRW Fast 100. October has proven to be a highly rewarding month for our team, after

2015 App Design Award Winners!

Recommended By

Another great win for the b2cloud team, being recognised by the App Design Awards for our incredible work with Catch of the Day owned Yumtable. The industry awarded b2cloud 2 Silver awards for the Best

Woes of KeychainWrapper and NSAssert

Thoughts By 5 years ago

If you have ever needed to store a password or other sensitive data in an iPhone app, you have probably used Keychain Access, Apple’s solution to storing data securely. You have also probably used Apple’s KeychainWrapper class, offering a very easy wrapper to storing info in the keychain.

The KeychainWrapper worked well in debug mode, but when building for release it didn’t seem to be writing objects to the keychain. I was fumbling around with this for hours, going over my own code thinking I had made a mistake somewhere. In the end I figured out what the problem was, in Apple’s code for KeychainWrapper the actual line that executed the commit to the keychain was inside an NSAssert, which is used for development, but as soon as you build for release or distribution every NSAssert is nullified, giving the same effect of commenting out anything on that line, removing the keychain commit code.