It can happen to anyone. You've changed the passcode on your iPhone, iPad, or iPod touch and all of a sudden you don't have a clue what your new code is. Or maybe you've had the same code for a long time, but it just suddenly slipped your mind. What should you do in such a case?
How crazy... The passcode you entered to unlock your device is not working. Maybe you made a typo? Try again. Not good again. Suddenly you remember: you changed the code last night after a long day at work, without really thinking about it. But in what? You have a few ideas of what it could be and try them out. And then it's wrong. Your device is blocked. Also read: How to restore the factory settings of your smartphone.
If you enter the wrong passcode six times in a row on an iOS device, the device will lock and you'll see a notification. You can wait a minute to try again (and longer and longer intervals after that), which is helpful if your code is suddenly shooting you up again. But if you really don't have a clue, or if you've tried it so many times that it's no longer possible, you need to restore your device.
Restore with iTunes
If your device is synced with iTunes, you can restore it by linking it to the computer you usually sync with.
Open iTunes. If prompted for the passcode or permission to access, try another computer you synced with, or use recovery mode (see below).
If you can open iTunes on a computer without prompting for the passcode or permission, iTunes will automatically sync the device and create a backup. If not, you'll need to manually sync the device with iTunes. After the sync is complete, you need to restore the device in iTunes.
Then select restore iTunes backup when the iOS Setup Assistant prompts you to set up your device. Select the device in iTunes and choose the most recent backup.
Restore with Find My iPhone
If you have enabled Find My iPhone via iCloud, you can use it to remotely wipe your device.
Go to //www.icloud.com/find and sign in with your Apple ID. Then click All devices at the top of your browser window and select the device you want to wipe. click on Clear [device name] to clear the device and passcode.
Then you can use Setup Assistant to restore the most recent backup to your device.
Recover with Recovery Mode
If you have never synced your device or have not set up the Find My iPhone feature, you will need to use recovery mode to erase the device and passcode. You can choose to restore factory settings or restore a backup.
First, make sure your device is not plugged in. Press and hold the snooze button and choose Turn off. The device will then be turned off. Hold down the home button and plug the device into your computer. If your device doesn't turn on automatically, you'll need to turn it on yourself without releasing the home button. You have to hold the home button until the screen Connect to iTunes is displayed. If you don't see this screen, you need to open iTunes yourself. You will then see a warning in iTunes that a device has been found in recovery mode. click on OK and restore the device to the most recent backup or factory settings.
Tip: You can choose to have your device wiped automatically when an incorrect passcode has been entered ten times in a row. By default, this setting is disabled, but in Settings > Passcode can you enable it.