The following comes to us from LifeHacker.com:
What To Do If You’ve Forgotten Your iPhone’s Passcode
Some passcodes are so effective that even you can’t remember what they are. If you’ve locked yourself out of your iPhone, it’s not to complicated to get back in. Here’s how.
The Methods That Don’t Work
There are plenty of methods on the internet claiming to help you bypass the password you’ve set on your lock screen but most of them are ineffective. Older versions of iOS had a bug that allowed you to sneak in by making a fake emergency call. This no longer works. Other tutorials suggest that you can delete the passcode file from your iPhone’s keychain directory using iExplorer, iPhone Browser, or SSH on your jailbroken device. That no longer works either. We even tested to see if Find My iPhone’s passcode lock tool would allow us to set a new passcode lock and overwrite the one you’d forgotten. It does not.
While you’re welcome to try out any methods you do find online, we’ve tested as many as we could locate and only one works. If you’d rather not spend your time trying tricks that no longer work, read on for instructions on the official method that does.
The Method That Always Works
Restoring your iPhone is a surefire way to wipe out the passcode or password you can’t remember, but performing a normal restore won’t work as your passcode will prevent it. (Arrgh!) Fortunately, this is easy to override. Just follow these steps:
Even when your iPhone is locked up, you can still sync it with your computer. Do that first so all your data is backed up in iTunes. If you’re using iCloud, you might want to switch it over to your computer for now just to be sure your information is safe.
Put your iPhone into DFU mode. To do this, reboot your iPhone by holding down the power and home buttons simultaneously for about 10 seconds. When you see the Apple logo, let go of the power button but continue holding down the home button. Soon you will see an image displaying a USB cable, the iTunes icon, and a message that says “Connect to iTunes.”
Assuming you still have your iPhone connected to your computer with iTunes open, you’ll also see a message telling you iTunes has detected an iPhone in recovery mode and needs to restore. Now you can click the Restore button in iTunes and then wait for iOS to download and install on your iPhone.
Sync your iPhone with iTunes to restore all your data and you’ll have it back to normal with no password!
It would be great if there were a simpler method, like some of the non-working options mentioned earlier, but unfortunately you have to go through this DFU restore process in order to get things back to normal. On the plus side, you know your iPhone’s data is pretty securely locked down—so much so that even you couldn’t get in.