Core Data + Passwords in Keychain

In an iPhone app project I’ve been working on recently, we needed to store sensitive information in a Core Data database. Without going into too much detail, let’s say we wanted to fill an Account table with usernames and passwords, but, of course, we couldn’t just store the passwords in clear text in the database.

Researching about best practices to do this, I came across this little great article. According to the author, “the keychain is about the only place that an iPhone application can safely store data”, referring to the Keychain Services in iOS. The author also provides some useful methods to make accessing the Keychain less of a pain.

Based on that article, I’ll show you an example of how to combine both Core Data with the Keychain to store passwords securely and seamlessly in NSManagedObject classes.

Continue reading

Advertisements

Dismissing MPMoviePlayerViewController the right way

If you have used the MPMoviePlayerViewController to play videos in iOS, chances are you have gotten a little frustrated by its rigidness. A couple of issues I personally encountered were:

  • When presented modally, the view controller did not respect the modal transition style I had chosen for it.
  • When the video finished playing, the view controller dismissed itself automatically. I wanted it to remain visible until the user pressed the Done button.

A couple of hours of browsing for the solution to no avail, I decided to try out sort of a hack, which turned out to work great.

Continue reading

Overlaying the iPhone camera without blocking its controls

While developing FaceMerge, an iPhone/iPod app that lets you take pictures of people and merge them into funny faces, I came across a problem while overlaying the camera. I wanted to provide the user with just a bit of guidance while taking pictures within my app.

Since iOS 3.1, the UIImagePickerController class has a property named cameraOverlayView; setting a UIView of your own to this property causes it to appear on top of the camera when the picker is displayed.

I did just that: I created a custom UIView named CameraView, which had no background color and only one label on it; and then I set it to the picker. When the picker showed up, everything looked OK, but the camera controls did not respond to any touch event.

Continue reading