I’m trying to understand the exact role of the return value in the UITextFieldDelegate method
textFieldShouldReturn(_:).
From my experiments in Xcode, I observed:
-
Returning true vs false does not seem to cause any visible difference (e.g., the keyboard does not automatically dismiss either way).
-
I know that in
shouldChangeCharactersIn
returning true allows the system to insert the character, and returning false prevents it. That’s clear. -
For
textFieldShouldReturn,
my current understanding is that returning true means “let the OS handle the Return press,” and returning false means “I’ll handle it myself.”
My confusion: what is it that the OS actually does when it “handles” the Return press?
- Does UIKit do anything beyond calling this delegate method?
- If the system is supposed to dismiss the keyboard when returning true, why doesn’t it happen automatically?
I’d appreciate clarification on the expected use of this return value — specifically, what default behavior the system performs (if any) when we return true.
Thanks!