The Apple might lock access if there are too many failed attempts at guessing the correct code. While this might be a scary and frustrating experience, it can be resolved given some time and patience.
Apple has always taken iPhone security seriously since it's a portable collection of all of the 's most important s, s, and payment methods. In the past, a lost code required a connection to a computer to clear a lockout. In the middle of what might be a terrible experience, the good news is that getting to the factory reset and restoring from a backup is faster and easier than ever.
This isn't a way for a thief to by the code since Apple requests the with their Apple ID before erasing the iPhone, restoring it to factory settings and clearing data. Afterward, the iPhone can be set up as new with a new code, and data can be restored from a backup.
Other iPhone Unlocking Options
If the steps above don't work, such as having no internet connection or using an older version of iOS, a factory reset is still possible but requires a computer. While all recent iPhone models come with either Touch ID or Face ID, some s might choose to skip the biometric authentication option, using the code instead. Or it might not be possible due to some unforeseen circumstances, such as damage to the fingerprint sensor or the TrueDepth camera system. Of course, bandages will also block biometric scans, requiring the code's fallback.
codes are typically 6-digit numbers, but Apple provides options for shorter 4-digit codes, as well as more extended codes that can include both letters and numbers. Even with Face ID or Touch ID working, there are times when the code is necessary, so it's imperative to pick a memorable code yet not easy to guess. Ideally, codes shouldn't be written down, but if forgetting is a common issue, writing it down and storing it in a safe location could help prevent the need to factory reset the iPhone after a lockout.
Source: Apple